utils.py
General-purpose utilities
from_camel_case(s)
¶
Convert names in camel case into underscore (_) separated names
:param s: string in CamelCase notation :returns: string in under_score notation Example:
from_camel_case("TableName") # yields "table_name"
Source code in datajoint/utils.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
|
get_master(full_table_name)
¶
If the table name is that of a part table, then return what the master table name would be.
This follows DataJoint's table naming convention where a master and a part must be in the
same schema and the part table is prefixed with the master table name + __
.
Example
ephys
.session
-- master
ephys
.session__recording
-- part
:param full_table_name: Full table name including part. :type full_table_name: str :return: Supposed master full table name or empty string if not a part table name. :rtype: str
Source code in datajoint/utils.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
|
parse_sql(filepath)
¶
yield SQL statements from an SQL file
Source code in datajoint/utils.py
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
|
safe_copy(src, dest, overwrite=False)
¶
Copy the contents of src file into dest file as a two-step process. Skip if dest exists already
Source code in datajoint/utils.py
107 108 109 110 111 112 113 114 115 116 |
|
safe_write(filepath, blob)
¶
A two-step write.
:param filename: full path :param blob: binary data
Source code in datajoint/utils.py
92 93 94 95 96 97 98 99 100 101 102 103 104 |
|
to_camel_case(s)
¶
Convert names with under score (_) separation into camel case names.
:param s: string in under_score notation :returns: string in CamelCase notation Example:
to_camel_case("table_name") # returns "TableName"
Source code in datajoint/utils.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
|
user_choice(prompt, choices=('yes', 'no'), default=None)
¶
Prompts the user for confirmation. The default value, if any, is capitalized.
:param prompt: Information to display to the user. :param choices: an iterable of possible choices. :param default: default choice :return: the user's choice
Source code in datajoint/utils.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
|