Package amplee :: Module utils
[hide private]
[frames] | no frames]

Module utils

source code


A few simple helpers



Functions [hide private]
  generate_uuid(seed=None)
Returns a uuid value.
  generate_uri(scheme, authority, trail)
Builds an URI as an unicode object Keyword arguments: scheme -- URI scheme (e.g.
  generate_uuid_uri(seed=None)
...
  compute_etag(seed)
...
  get_isodate(dt=None)
...
  parse_isodate(value)
attempts to parse value as an ISO date and if succeeding returns a datetime object, None otherwise.
  create_temporary_resource(content)
...
  delete_temporary_resource(path)
...

Function Details [hide private]

generate_uuid(seed=None)

source code 

Returns a uuid value.

Keyword arguments:
seed -- if provided, builds a uuid from it
otherwise returns a random uuid

generate_uri(scheme, authority, trail)

source code 

Builds an URI as an unicode object

Keyword arguments:
scheme -- URI scheme (e.g. http)
authority -- hostname
trail -- URI path

generate_uuid_uri(seed=None)

source code 

Returns an URN from uuid

compute_etag(seed)

source code 

Returns a hash value of seed

get_isodate(dt=None)

source code 

returns a date respecting ISO 8601 format

parse_isodate(value)

source code 

attempts to parse value as an ISO date and if succeeding returns
a datetime object, None otherwise.

Keyword arguments:
value -- a date in a string format

create_temporary_resource(content)

source code 

Dump the content into a temp file and returns
the file handle, the absolute path of the temp file
as well as the content as a string

Keyword arguments:
content -- string object

delete_temporary_resource(path)

source code 

Safely removes path

Keyword argument:
path -- a file-system path