Check if the filename can be processed by any of the registered methods.
Parameter: | filename (string) – filename |
---|
Get all methods registered for an extension.
Parameter: | extension (string) – file extension |
---|---|
Returns: | list of methods registered for the extension |
Return type: | list |
Register one method for multiple extensions. If the method is None, it will cancel the registration.
Parameters: |
|
---|
Unregister an extension from all methods.
Parameter: | extensions (list of strings) – list of file extensions |
---|
Unregister a method from all extensions.
Parameters: |
|
---|
It is important to call this method when finished with the temporary file.
Parameters: |
|
---|
Runs a shell command and returns it’s exit code. This also is an obligatory alternative to subprocess.call as that won’t work with py2exe.
Parameter: | args (tuple of strings) – the command to be executed in the shell |
---|---|
Returns: | command exit code |
Return type: | integer |
Runs a shell command and captures the output.
Parameter: | args (tuple of strings) – the command to be executed in the shell |
---|---|
Returns: | stdout, stderr and return code |
Return type: | tuple of (str, str, int) |
The options will be passed to the subprocess.Popen
>>> call_out_err(['echo', 'world'])
('world\n', '', 0)
Same function as call_out_err() but hacks around problematic unicode filenames with temp files. This will probably only be needed by certain Windows programs.
We can’t use hard links as on windows that only works for NTFS.
Parameters: |
|
---|---|
Returns: | stdout, stderr and return code |
Return type: | tuple of (str, str, int) |
Ensure a path exists, create all not existing paths.
It raises an OSError, if an invalid path is specified.
Parameter: | path (str) – the absolute folder path (not relative!) |
---|
Converts a filename to a title. It replaces dashes with spaces and converts every first character to uppercase.
Parameter: | filename (str) – an absolute or relative path |
---|---|
Returns: | titled version of the filename |
Return type: | bool |
>>> filename_to_title('~/highlight_mask.png')
'Highlight Mask'
Find command in text
Parameter: | text (string) – command line |
---|---|
Returns: | text |
Return type: | text |
>>> find_command('convert image.jpg image.jpg')
'convert'
>>> find_command('"/my apps/convert" image.jpg image.jpg')
'"/my apps/convert"'
>>> find_command('/my apps/convert image.jpg image.jpg')
'/my'
Finds an executable binary. Returns None if the binary can not be found.
This method need some extra love for Windows and Mac.
Parameters: |
|
---|---|
Returns: | absolute path to the binary |
Return type: | string or None |
Finds a filename in a list of paths.
Parameters: |
|
---|---|
Returns: | found filename with path or None |
Return type: | string or None |
Fix quotes for a command line parameter. Only surround by quotes if a space is present in the filename.
Parameter: | text (string) – command line parameter |
---|---|
Returns: | text with quotes if needed |
Return type: | string |
>>> fix_quotes('blender')
'blender'
>>> fix_quotes('/my programs/blender')
'"/my programs/blender"'
Checks wether a path is a valid local or remote file.
Parameter: | path (str) – the path which has to be checked |
---|---|
Returns: | True if path is a valid local or remote file, False otherwise |
Return type: | bool |
>>> is_file('http://www.foo.com/logo.png')
True
>>> is_file('ftp://foo.com/logo.png')
True
>>> is_file('/etc/fstap')
False
Checks whether a file is remote (http or ftp).
Parameter: | url (str) – file path or url |
---|---|
Returns: | True if remote, False if local |
Return type: | bool |
>>> is_www_file('http://www.foo.com/logo.png')
True
>>> is_www_file('ftp://foo.com/logo.png')
True
>>> is_www_file('logo.png')
False
Initializes where binaries can be found.
Parameter: | paths (list of strings) – list of paths where binaries might be found |
---|
Runs a shell command and captures the output. It uses a caching system so that cached results don’t need to run a subprocess anymore. The results are cached by sys.platform
Parameters: |
|
---|---|
Returns: | stdout and stdout |
Return type: | typle of strings |
Open a file or browse a folder.
Parameter: | path (string) – location of the file |
---|
Turns a text in a title
Parameter: | text (str) – text |
---|---|
Returns: | title |
Return type: | str |
>>> title('hello_world')
'Hello World'