doapfiend.utils

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

# Module utils

source code

# utils.py

## Misc utilities for doapfiend

General purpose helper functions and classes for doapfiend You'll probably want to use doaplib for most cases.

License: BSD-2

Classes | [hide private]
| NotFoundError DOAP not found
| DoapPrinter Prints DOAP in human readable text

Functions | [hide private]
string |
http_filesize(url) Get the size of file without downloading it. | source code
boolean |
http_exists(url) A quick way to check if a file exists on the web. | source code
boolean |
is_content_type(url_or_file, content_type) Tells whether the URL or pseudofile from urllib.urlopen is of the required content type. | source code
string |
pretty_name(field) Convert DOAP element name to pretty printable label | source code
string |
get_n3(xml_text) Return N3 (Notation 3) text | source code
None |
print_misc_field(label, text) Print colorized and justified single label value pair | source code
string |
fetch_file(url, proxy=None) Download file by URL | source code

Variables | [hide private]
| FOAF = `rdflib.URIRef('http://xmlns.com/foaf/0.1/')`
| LOG = `logging.getLogger('doapfiend')`
| color = ``{``'``black``'``:` `'``\x1b[30m``'``,` `'``blink``'``:` `'``\x1b[5m``'``,` `'``blue``'``:` `'``\x1``...``

Function Details | [hide private]

### http_filesize(url) | source code
  Get the size of file without downloading it. bla bla bla blaba Parameters: `url` (string) - URL of file Returns: string Size of file Usage:
      >>> http_filesize('http://trac.doapspace.org/test_file.txt')
      '160'

### http_exists(url) | source code
  A quick way to check if a file exists on the web. Parameters: `url` (string) - URL of the document Returns: boolean True or False Usage:
      >>> http_exists('http://www.python.org/')
      True
      >>> http_exists('http://www.python.org/PenguinOnTheTelly')
      False

### is_content_type(url_or_file, content_type) | source code
  Tells whether the URL or pseudofile from urllib.urlopen is of the required content type. Parameters: `url_or_file` (string) - URL or file path `content_type` (string) - Content type we're looking for Returns: boolean True if it can return the Content type we want Usage:
      >>> is_content_type('http://doapspace.org/doap/sf/nlyrics.rdf',             'application/rdf+xml')
      True
      >>> is_content_type('http://doapspace.org/', 'application/rdf+xml')
      False

### pretty_name(field) | source code
Convert DOAP element name to pretty printable label Parameters: `field` (`string`) - Text to be formatted Returns: string formatted string

### get_n3(xml_text) | source code
Return N3 (Notation 3) text Parameters: `xml_text` (string) - XML/RDF Returns: string Notation 3

### print_misc_field(label, text) | source code
Print colorized and justified single label value pair Parameters: `label` (string) - A label `text` (string) - Text to print Returns: None Nothing

### fetch_file(url, proxy=None) | source code
Download file by URL Parameters: `url` (string) - URL of a file `proxy` (string) - URL of HTTP Proxy Returns: string File

Variables Details | [hide private]

  ### color Value:
      {'black': '\x1b[30m',
       'blink': '\x1b[5m',
       'blue': '\x1b[34m',
       'bold': '\x1b[1m',
       'cyan': '\x1b[36m',
       'green': '\x1b[32m',
       'magenta': '\x1b[35m',
       'normal': '\x1b[0m',
      ...