|
pycrossword
0.3
Pure-Python implementation of a crossword puzzle generator and editor
|
Classes | |
| class | JsonHiliter |
| Syntax highlighter class for JSON. More... | |
| class | QThreadStump |
| Customized thread class (based on QThread) that adds progress, error etc. More... | |
Functions | |
| def | is_iterable (obj) |
| Checks if a given object is iterable (i.e. More... | |
| def | getosname () |
| Gets the current OS (platform) name. More... | |
| def | generate_uuid () |
| Generates a random UUID (alphanumeric string). More... | |
| def | copy_file (path_from, path_to) |
| Copies a file into another location. More... | |
| def | walk_dir (root_path, abs_path=True, recurse=True, dir_process_function=None, file_process_function=None, file_types=None) |
| Iterates the files and folder in a given folder, performing some operations on the found files / folders. More... | |
| def | run_exe (args, external=False, capture_output=True, stdout=subprocess.PIPE, encoding=ENCODING, timeout=None, shell=False, **kwargs) |
| Runs an executable and optionally returns the result. More... | |
| def | datetime_to_str (dt=None, strformat='%Y-%m-%d %H-%M-%S') |
Converts a Python datetime object to a string. More... | |
| def | timestamp_to_str (ts=None, strformat='%Y-%m-%d %H-%M-%S') |
| Converts a timestamp (Unix time) to a string. More... | |
| def | str_to_datetime (text, strformat='%Y-%m-%d %H-%M-%S') |
Converts a string to a Python datetime object. More... | |
| def | str_to_timestamp (text, strformat='%Y-%m-%d %H-%M-%S') |
| Converts a string to a timestamp (Unix time). More... | |
| def | get_tempdir () |
| Gets the path to the Temp directory on the system. More... | |
| def | bytes_human (value, suffix='B') |
| Returns a human-formatted file size as a string, e.g. More... | |
| def | restart_app (closefunction) |
| Restarts this app. More... | |
| def | file_types_registered (filetypes=('xpf', 'ipuz', 'pxjson')) |
| Checks if the given file type associations are registered in the OS. More... | |
| def | register_file_types (filetypes=('xpf', 'ipuz', 'pxjson'), register=True) |
| Registers file associations in the current OS for the given file types and application. More... | |
| def | make_font (family, size=-1, weight=-1, italic=False, font_unit='pt') |
| def | MsgBox (what, parent=None, title='pyCross', msgtype='info', btn=None, detailedText='', infoText='', execnow=True) |
| def | UserInput (dialogtype='text', parent=None, title='pyCross', label='', value=None, textmode='normal', valrange=None, decimals=1, step=1, comboeditable=True, comboitems=[]) |
| def | clipboard_copy (value, valtype='text') |
| def | clipboard_get (valtype='text') |
| def | clipboard_clear () |
| def | stylesheet_load (style, dequote=True, strip_sz=True, units=('pt', 'px')) |
| def | stylesheet_dump (d, quoted_keys=('font-family',), add_units={ 'font-size':'pt', 'border':'px', 'border-width':'px'}) |
| def | font_weight_css2qt (weight, default=0) |
| def | font_weight_qt2css (weight, default=0) |
| def | font_from_stylesheet (style, font_unit='pt', default_font=None) |
| def | font_to_stylesheet (font, style, font_unit='pt') |
| def | color_from_stylesheet (style, tag='background-color', default='black') |
| def | color_to_stylesheet (color, style, tag='background-color') |
| def | property_to_stylesheet (propname, propvalue, style) |
| def | property_from_stylesheet (propname, style, default=None) |
Variables | |
| dictionary | MSGBOX_BUTTONS |
| dictionary | MSGBOX_TYPES |
| def pycross.utils.utils.bytes_human | ( | value, | |
suffix = 'B' |
|||
| ) |
Returns a human-formatted file size as a string, e.g.
"1Mi" (1 megabyte), "15GBi" (15 gigabytes) etc.
| value | float the file size value to convert |
| suffix | str the size suffix, default = 'B' (bytes) |
str string representation of the file size | def pycross.utils.utils.clipboard_clear | ( | ) |
| def pycross.utils.utils.clipboard_copy | ( | value, | |
valtype = 'text' |
|||
| ) |
| def pycross.utils.utils.clipboard_get | ( | valtype = 'text' | ) |
| def pycross.utils.utils.color_from_stylesheet | ( | style, | |
tag = 'background-color', |
|||
default = 'black' |
|||
| ) |
| def pycross.utils.utils.color_to_stylesheet | ( | color, | |
| style, | |||
tag = 'background-color' |
|||
| ) |
| def pycross.utils.utils.copy_file | ( | path_from, | |
| path_to | |||
| ) |
Copies a file into another location.
| path_from | str the original file to copy |
| path_to | str the new file path or directory to copy the file to |
str the path to the newly created (copied) file | def pycross.utils.utils.datetime_to_str | ( | dt = None, |
|
strformat = '%Y-%m-%d %H-%M-%S' |
|||
| ) |
Converts a Python datetime object to a string.
| dt | datetime Python datetime object representing a date and/or time; if None (default), the current date and time will be taken |
| strformat | str format string compliant to the Python datetime formatting |
str string representation of the date / time | def pycross.utils.utils.file_types_registered | ( | filetypes = ('xpf', 'ipuz', 'pxjson') | ) |
Checks if the given file type associations are registered in the OS.
| filetypes | iterable collection of file extensions to check (without leading dot) |
bool True if the file types are associated with this app, False otherwise TODO: implement for OSX (Darwin) | def pycross.utils.utils.font_from_stylesheet | ( | style, | |
font_unit = 'pt', |
|||
default_font = None |
|||
| ) |
| def pycross.utils.utils.font_to_stylesheet | ( | font, | |
| style, | |||
font_unit = 'pt' |
|||
| ) |
| def pycross.utils.utils.font_weight_css2qt | ( | weight, | |
default = 0 |
|||
| ) |
| def pycross.utils.utils.font_weight_qt2css | ( | weight, | |
default = 0 |
|||
| ) |
| def pycross.utils.utils.generate_uuid | ( | ) |
Generates a random UUID (alphanumeric string).
str UUID compliant to RFC 4122 | def pycross.utils.utils.get_tempdir | ( | ) |
Gets the path to the Temp directory on the system.
str full path to the system Temp directory | def pycross.utils.utils.getosname | ( | ) |
Gets the current OS (platform) name.
str platform name, e.g. 'Windows' or 'Linux' | def pycross.utils.utils.is_iterable | ( | obj | ) |
Checks if a given object is iterable (i.e.
contains elements like an array).
| obj | the object to check |
bool True if the object is iterable (array-like) and False otherwise | def pycross.utils.utils.make_font | ( | family, | |
size = -1, |
|||
weight = -1, |
|||
italic = False, |
|||
font_unit = 'pt' |
|||
| ) |
| def pycross.utils.utils.MsgBox | ( | what, | |
parent = None, |
|||
title = 'pyCross', |
|||
msgtype = 'info', |
|||
btn = None, |
|||
detailedText = '', |
|||
infoText = '', |
|||
execnow = True |
|||
| ) |
| def pycross.utils.utils.property_from_stylesheet | ( | propname, | |
| style, | |||
default = None |
|||
| ) |
| def pycross.utils.utils.property_to_stylesheet | ( | propname, | |
| propvalue, | |||
| style | |||
| ) |
| def pycross.utils.utils.register_file_types | ( | filetypes = ('xpf', 'ipuz', 'pxjson'), |
|
register = True |
|||
| ) |
Registers file associations in the current OS for the given file types and application.
After a call of this method succeeds, files with the indicated extensions can be launched directly with the 'open' verb, that is, by double-clicking or hitting Enter on them in the system file browser. These files will be opened with pycrossword thanks to the system-wide permanent file associations. The mechanism uses the System Registry on Windows and MIME types on Linux.
| filetypes | iterable collection of file extensions to check (without leading dot) |
| register | bool set True to register the associations, False to unregister TODO: implement for OSX (Darwin) |
| def pycross.utils.utils.restart_app | ( | closefunction | ) |
Restarts this app.
| closefunction | callable function to close down the app (e.g. gui::MainWindow::on_act_exit) |
| def pycross.utils.utils.run_exe | ( | args, | |
external = False, |
|||
capture_output = True, |
|||
stdout = subprocess.PIPE, |
|||
encoding = ENCODING, |
|||
timeout = None, |
|||
shell = False, |
|||
| ** | kwargs | ||
| ) |
Runs an executable and optionally returns the result.
| args | list | str arguments passed to the executable (a list of args or a single string) |
| external | bool whether the executable must be called as an external (detached) process; this basically means that the process will be created asynchronously, not blocking the main application process to wait for the result; if False (default), the executable will be called synchronously, waiting for the result and blocking the main process |
| capture_output | bool whether the console output of the executable must be captured |
| stdout | file-like file / stream to channel the STDOUT and STDERR streams to; the default value is subprocess.PIPE, meaning that the output will be returned by the method |
| encoding | str the string encoding to use for the executable's output (default = UTF8) |
| timeout | float number of seconds to wait until timeout (default = None, i.e. wait infinitely) |
| shell | bool whether the executable must be called via the system shell (default = False) |
| kwargs | keyword arguments additional keyword arguments passed to subprocess.Popen |
subprocess.CompletedProcess completed process results, see Python docs | def pycross.utils.utils.str_to_datetime | ( | text, | |
strformat = '%Y-%m-%d %H-%M-%S' |
|||
| ) |
Converts a string to a Python datetime object.
| text | str datetime string to convert |
| strformat | str format string compliant to the Python datetime formatting |
datetime Python datetime object | def pycross.utils.utils.str_to_timestamp | ( | text, | |
strformat = '%Y-%m-%d %H-%M-%S' |
|||
| ) |
Converts a string to a timestamp (Unix time).
| text | str datetime string to convert |
| strformat | str format string compliant to the Python datetime formatting |
float timestamp, i.e. number of seconds since epoch (Unix time) | def pycross.utils.utils.stylesheet_dump | ( | d, | |
quoted_keys = ('font-family',), |
|||
add_units = {'font-size': 'pt', 'border': 'px', 'border-width': 'px'} |
|||
| ) |
| def pycross.utils.utils.stylesheet_load | ( | style, | |
dequote = True, |
|||
strip_sz = True, |
|||
units = ('pt', 'px') |
|||
| ) |
| def pycross.utils.utils.timestamp_to_str | ( | ts = None, |
|
strformat = '%Y-%m-%d %H-%M-%S' |
|||
| ) |
Converts a timestamp (Unix time) to a string.
| ts | float timestamp, i.e. number of seconds since epoch (Unix time) if None (default), the current timestamp will be taken |
| strformat | str format string compliant to the Python datetime formatting |
str string representation of the timestamp | def pycross.utils.utils.UserInput | ( | dialogtype = 'text', |
|
parent = None, |
|||
title = 'pyCross', |
|||
label = '', |
|||
value = None, |
|||
textmode = 'normal', |
|||
valrange = None, |
|||
decimals = 1, |
|||
step = 1, |
|||
comboeditable = True, |
|||
comboitems = [] |
|||
| ) |
| def pycross.utils.utils.walk_dir | ( | root_path, | |
abs_path = True, |
|||
recurse = True, |
|||
dir_process_function = None, |
|||
file_process_function = None, |
|||
file_types = None |
|||
| ) |
Iterates the files and folder in a given folder, performing some operations on the found files / folders.
| root_path | str the starting (root) directory path to start searching from |
| abs_path | bool if True (default), the given root path will be made absolute (relative to the current working directory); if False, it will be left as it is |
| recurse | bool whether to recurse into the found subdirectories (default = True) |
| dir_process_function | callable callback function for found subdirectories. The callback takes a single argument - the full directory path. |
| file_process_function | callable callback function for found files. The callback takes a single argument - the full file path. |
| file_types | iterable collection of file extensions (without the leading dot) that will be respected when a file is found; if None (default), no file type filtering will be done. |
| dictionary pycross.utils.utils.MSGBOX_BUTTONS |
| dictionary pycross.utils.utils.MSGBOX_TYPES |
1.8.17