Search is not available for this dataset
identifier
stringlengths
1
155
parameters
stringlengths
2
6.09k
docstring
stringlengths
11
63.4k
docstring_summary
stringlengths
0
63.4k
function
stringlengths
29
99.8k
function_tokens
list
start_point
list
end_point
list
language
stringclasses
1 value
docstring_language
stringlengths
2
7
docstring_language_predictions
stringlengths
18
23
is_langid_reliable
stringclasses
2 values
DummyScreen.draw_screen
(self, size, canvas)
:param size: :type canvas: urwid.Canvas
def draw_screen(self, size, canvas): """ :param size: :type canvas: urwid.Canvas """ data = "" for char in canvas.content(): line = "" for part in char: if isinstance(part[2], str): line += part[2] ...
[ "def", "draw_screen", "(", "self", ",", "size", ",", "canvas", ")", ":", "data", "=", "\"\"", "for", "char", "in", "canvas", ".", "content", "(", ")", ":", "line", "=", "\"\"", "for", "part", "in", "char", ":", "if", "isinstance", "(", "part", "[",...
[ 1604, 4 ]
[ 1620, 67 ]
python
en
['en', 'error', 'th']
False
extract_sources
(accessor, extraction_params)
Extract sources from an image. args: images: a tuple of image DB object and accessor extraction_params: dictionary containing at least the detection and analysis threshold and the association radius, the last one a multiplication factor of the de Ruiter radius. ret...
Extract sources from an image.
def extract_sources(accessor, extraction_params): """ Extract sources from an image. args: images: a tuple of image DB object and accessor extraction_params: dictionary containing at least the detection and analysis threshold and the association radius, the last one a ...
[ "def", "extract_sources", "(", "accessor", ",", "extraction_params", ")", ":", "logger", ".", "debug", "(", "\"Detecting sources in image %s at detection threshold %s\"", ",", "accessor", ",", "extraction_params", "[", "'detection_threshold'", "]", ")", "data_image", "=",...
[ 14, 0 ]
[ 57, 30 ]
python
en
['en', 'error', 'th']
False
ordinal
(value)
Converts an integer to its ordinal as a string. 1 is '1st', 2 is '2nd', 3 is '3rd', etc. Works for any integer.
Converts an integer to its ordinal as a string. 1 is '1st', 2 is '2nd', 3 is '3rd', etc. Works for any integer.
def ordinal(value): """ Converts an integer to its ordinal as a string. 1 is '1st', 2 is '2nd', 3 is '3rd', etc. Works for any integer. """ try: value = int(value) except (TypeError, ValueError): return value suffixes = (_('th'), _('st'), _('nd'), _('rd'), _('th'), _('th'), _...
[ "def", "ordinal", "(", "value", ")", ":", "try", ":", "value", "=", "int", "(", "value", ")", "except", "(", "TypeError", ",", "ValueError", ")", ":", "return", "value", "suffixes", "=", "(", "_", "(", "'th'", ")", ",", "_", "(", "'st'", ")", ","...
[ 20, 0 ]
[ 33, 60 ]
python
en
['en', 'error', 'th']
False
intcomma
(value, use_l10n=True)
Converts an integer to a string containing commas every three digits. For example, 3000 becomes '3,000' and 45000 becomes '45,000'.
Converts an integer to a string containing commas every three digits. For example, 3000 becomes '3,000' and 45000 becomes '45,000'.
def intcomma(value, use_l10n=True): """ Converts an integer to a string containing commas every three digits. For example, 3000 becomes '3,000' and 45000 becomes '45,000'. """ if settings.USE_L10N and use_l10n: try: if not isinstance(value, (float, Decimal)): valu...
[ "def", "intcomma", "(", "value", ",", "use_l10n", "=", "True", ")", ":", "if", "settings", ".", "USE_L10N", "and", "use_l10n", ":", "try", ":", "if", "not", "isinstance", "(", "value", ",", "(", "float", ",", "Decimal", ")", ")", ":", "value", "=", ...
[ 37, 0 ]
[ 55, 38 ]
python
en
['en', 'error', 'th']
False
intword
(value)
Converts a large integer to a friendly text representation. Works best for numbers over 1 million. For example, 1000000 becomes '1.0 million', 1200000 becomes '1.2 million' and '1200000000' becomes '1.2 billion'.
Converts a large integer to a friendly text representation. Works best for numbers over 1 million. For example, 1000000 becomes '1.0 million', 1200000 becomes '1.2 million' and '1200000000' becomes '1.2 billion'.
def intword(value): """ Converts a large integer to a friendly text representation. Works best for numbers over 1 million. For example, 1000000 becomes '1.0 million', 1200000 becomes '1.2 million' and '1200000000' becomes '1.2 billion'. """ try: value = int(value) except (TypeError, ...
[ "def", "intword", "(", "value", ")", ":", "try", ":", "value", "=", "int", "(", "value", ")", "except", "(", "TypeError", ",", "ValueError", ")", ":", "return", "value", "if", "value", "<", "1000000", ":", "return", "value", "def", "_check_for_i18n", "...
[ 108, 0 ]
[ 138, 16 ]
python
en
['en', 'error', 'th']
False
apnumber
(value)
For numbers 1-9, returns the number spelled out. Otherwise, returns the number. This follows Associated Press style.
For numbers 1-9, returns the number spelled out. Otherwise, returns the number. This follows Associated Press style.
def apnumber(value): """ For numbers 1-9, returns the number spelled out. Otherwise, returns the number. This follows Associated Press style. """ try: value = int(value) except (TypeError, ValueError): return value if not 0 < value < 10: return value return (_('on...
[ "def", "apnumber", "(", "value", ")", ":", "try", ":", "value", "=", "int", "(", "value", ")", "except", "(", "TypeError", ",", "ValueError", ")", ":", "return", "value", "if", "not", "0", "<", "value", "<", "10", ":", "return", "value", "return", ...
[ 142, 0 ]
[ 154, 67 ]
python
en
['en', 'error', 'th']
False
naturalday
(value, arg=None)
For date values that are tomorrow, today or yesterday compared to present day returns representing string. Otherwise, returns a string formatted according to settings.DATE_FORMAT.
For date values that are tomorrow, today or yesterday compared to present day returns representing string. Otherwise, returns a string formatted according to settings.DATE_FORMAT.
def naturalday(value, arg=None): """ For date values that are tomorrow, today or yesterday compared to present day returns representing string. Otherwise, returns a string formatted according to settings.DATE_FORMAT. """ try: tzinfo = getattr(value, 'tzinfo', None) value = date(v...
[ "def", "naturalday", "(", "value", ",", "arg", "=", "None", ")", ":", "try", ":", "tzinfo", "=", "getattr", "(", "value", ",", "'tzinfo'", ",", "None", ")", "value", "=", "date", "(", "value", ".", "year", ",", "value", ".", "month", ",", "value", ...
[ 160, 0 ]
[ 183, 42 ]
python
en
['en', 'error', 'th']
False
naturaltime
(value)
For date and time values shows how many seconds, minutes or hours ago compared to current timestamp returns representing string.
For date and time values shows how many seconds, minutes or hours ago compared to current timestamp returns representing string.
def naturaltime(value): """ For date and time values shows how many seconds, minutes or hours ago compared to current timestamp returns representing string. """ if not isinstance(value, date): # datetime is a subclass of date return value now = datetime.now(utc if is_aware(value) else ...
[ "def", "naturaltime", "(", "value", ")", ":", "if", "not", "isinstance", "(", "value", ",", "date", ")", ":", "# datetime is a subclass of date", "return", "value", "now", "=", "datetime", ".", "now", "(", "utc", "if", "is_aware", "(", "value", ")", "else"...
[ 189, 0 ]
[ 253, 32 ]
python
en
['en', 'error', 'th']
False
Command.load_label
(self, fixture_label)
Loads fixtures files for a given label.
Loads fixtures files for a given label.
def load_label(self, fixture_label): """ Loads fixtures files for a given label. """ show_progress = self.verbosity >= 3 for fixture_file, fixture_dir, fixture_name in self.find_fixtures(fixture_label): _, ser_fmt, cmp_fmt = self.parse_name(os.path.basename(fixture_fi...
[ "def", "load_label", "(", "self", ",", "fixture_label", ")", ":", "show_progress", "=", "self", ".", "verbosity", ">=", "3", "for", "fixture_file", ",", "fixture_dir", ",", "fixture_name", "in", "self", ".", "find_fixtures", "(", "fixture_label", ")", ":", "...
[ 142, 4 ]
[ 205, 17 ]
python
en
['en', 'error', 'th']
False
Command.find_fixtures
(self, fixture_label)
Finds fixture files for a given label.
Finds fixture files for a given label.
def find_fixtures(self, fixture_label): """ Finds fixture files for a given label. """ fixture_name, ser_fmt, cmp_fmt = self.parse_name(fixture_label) databases = [self.using, None] cmp_fmts = list(self.compression_formats.keys()) if cmp_fmt is None else [cmp_fmt] ...
[ "def", "find_fixtures", "(", "self", ",", "fixture_label", ")", ":", "fixture_name", ",", "ser_fmt", ",", "cmp_fmt", "=", "self", ".", "parse_name", "(", "fixture_label", ")", "databases", "=", "[", "self", ".", "using", ",", "None", "]", "cmp_fmts", "=", ...
[ 208, 4 ]
[ 262, 28 ]
python
en
['en', 'error', 'th']
False
Command.fixture_dirs
(self)
Return a list of fixture directories. The list contains the 'fixtures' subdirectory of each installed application, if it exists, the directories in FIXTURE_DIRS, and the current directory.
Return a list of fixture directories.
def fixture_dirs(self): """ Return a list of fixture directories. The list contains the 'fixtures' subdirectory of each installed application, if it exists, the directories in FIXTURE_DIRS, and the current directory. """ dirs = [] fixture_dirs = settings....
[ "def", "fixture_dirs", "(", "self", ")", ":", "dirs", "=", "[", "]", "fixture_dirs", "=", "settings", ".", "FIXTURE_DIRS", "if", "len", "(", "fixture_dirs", ")", "!=", "len", "(", "set", "(", "fixture_dirs", ")", ")", ":", "raise", "ImproperlyConfigured", ...
[ 265, 4 ]
[ 293, 19 ]
python
en
['en', 'error', 'th']
False
Command.parse_name
(self, fixture_name)
Splits fixture name in name, serialization format, compression format.
Splits fixture name in name, serialization format, compression format.
def parse_name(self, fixture_name): """ Splits fixture name in name, serialization format, compression format. """ parts = fixture_name.rsplit('.', 2) if len(parts) > 1 and parts[-1] in self.compression_formats: cmp_fmt = parts[-1] parts = parts[:-1] ...
[ "def", "parse_name", "(", "self", ",", "fixture_name", ")", ":", "parts", "=", "fixture_name", ".", "rsplit", "(", "'.'", ",", "2", ")", "if", "len", "(", "parts", ")", ">", "1", "and", "parts", "[", "-", "1", "]", "in", "self", ".", "compression_f...
[ 295, 4 ]
[ 320, 37 ]
python
en
['en', 'error', 'th']
False
convert_to_cartesian
(conn, ra, decl)
Returns tuple (x,y,z)
Returns tuple (x,y,z)
def convert_to_cartesian(conn, ra, decl): """Returns tuple (x,y,z)""" qry = """SELECT x,y,z FROM cartesian(%s, %s)""" curs = conn.connection.cursor() curs.execute(qry, (ra, decl)) return curs.fetchone()
[ "def", "convert_to_cartesian", "(", "conn", ",", "ra", ",", "decl", ")", ":", "qry", "=", "\"\"\"SELECT x,y,z FROM cartesian(%s, %s)\"\"\"", "curs", "=", "conn", ".", "connection", ".", "cursor", "(", ")", "curs", ".", "execute", "(", "qry", ",", "(", "ra", ...
[ 16, 0 ]
[ 21, 26 ]
python
en
['en', 'pl', 'en']
True
get_assoc_entries
(db, runcat_id)
Return the full history of variability indices for a runcat entry, ordered by time.
Return the full history of variability indices for a runcat entry, ordered by time.
def get_assoc_entries(db, runcat_id): """ Return the full history of variability indices for a runcat entry, ordered by time. """ query = """\ select a.runcat ,a.xtrsrc ,x.extract_type ,i.taustart_ts ,a.v_int ,a.eta_int ,a.f_datapoints ...
[ "def", "get_assoc_entries", "(", "db", ",", "runcat_id", ")", ":", "query", "=", "\"\"\"\\\n select a.runcat\n ,a.xtrsrc\n ,x.extract_type\n ,i.taustart_ts\n ,a.v_int\n ,a.eta_int\n ,a.f_datapoints\n ,a.type\n ,r.mon_src\...
[ 23, 0 ]
[ 49, 42 ]
python
en
['en', 'error', 'th']
False
PostGISSchemaEditor._alter_column_type_sql
(self, table, old_field, new_field, new_type)
Special case when dimension changed.
Special case when dimension changed.
def _alter_column_type_sql(self, table, old_field, new_field, new_type): """ Special case when dimension changed. """ if not hasattr(old_field, 'dim') or not hasattr(new_field, 'dim'): return super(PostGISSchemaEditor, self)._alter_column_type_sql( table, old_...
[ "def", "_alter_column_type_sql", "(", "self", ",", "table", ",", "old_field", ",", "new_field", ",", "new_type", ")", ":", "if", "not", "hasattr", "(", "old_field", ",", "'dim'", ")", "or", "not", "hasattr", "(", "new_field", ",", "'dim'", ")", ":", "ret...
[ 42, 4 ]
[ 66, 9 ]
python
en
['en', 'error', 'th']
False
TestEmbedBlock.test_deserialize
(self)
Deserialising the JSONish value of an EmbedBlock (a URL) should give us an EmbedValue for that URL
Deserialising the JSONish value of an EmbedBlock (a URL) should give us an EmbedValue for that URL
def test_deserialize(self): """ Deserialising the JSONish value of an EmbedBlock (a URL) should give us an EmbedValue for that URL """ block = EmbedBlock(required=False) block_val = block.to_python('http://www.example.com/foo') self.assertIsInstance(block_val, Em...
[ "def", "test_deserialize", "(", "self", ")", ":", "block", "=", "EmbedBlock", "(", "required", "=", "False", ")", "block_val", "=", "block", ".", "to_python", "(", "'http://www.example.com/foo'", ")", "self", ".", "assertIsInstance", "(", "block_val", ",", "Em...
[ 703, 4 ]
[ 716, 47 ]
python
en
['en', 'error', 'th']
False
TestEmbedBlock.test_render_within_structblock
(self, get_embed)
When rendering the value of an EmbedBlock directly in a template (as happens when accessing it as a child of a StructBlock), the proper embed output should be rendered, not the URL.
When rendering the value of an EmbedBlock directly in a template (as happens when accessing it as a child of a StructBlock), the proper embed output should be rendered, not the URL.
def test_render_within_structblock(self, get_embed): """ When rendering the value of an EmbedBlock directly in a template (as happens when accessing it as a child of a StructBlock), the proper embed output should be rendered, not the URL. """ get_embed.return_value = Embe...
[ "def", "test_render_within_structblock", "(", "self", ",", "get_embed", ")", ":", "get_embed", ".", "return_value", "=", "Embed", "(", "html", "=", "'<h1>Hello world!</h1>'", ")", "block", "=", "blocks", ".", "StructBlock", "(", "[", "(", "'title'", ",", "bloc...
[ 746, 4 ]
[ 768, 75 ]
python
en
['en', 'error', 'th']
False
TestEmbedBlock.test_value_from_form
(self)
EmbedBlock should be able to turn a URL submitted as part of a form back into an EmbedValue
EmbedBlock should be able to turn a URL submitted as part of a form back into an EmbedValue
def test_value_from_form(self): """ EmbedBlock should be able to turn a URL submitted as part of a form back into an EmbedValue """ block = EmbedBlock(required=False) block_val = block.value_from_datadict({'myembed': 'http://www.example.com/foo'}, {}, prefix='myembed') ...
[ "def", "test_value_from_form", "(", "self", ")", ":", "block", "=", "EmbedBlock", "(", "required", "=", "False", ")", "block_val", "=", "block", ".", "value_from_datadict", "(", "{", "'myembed'", ":", "'http://www.example.com/foo'", "}", ",", "{", "}", ",", ...
[ 770, 4 ]
[ 783, 41 ]
python
en
['en', 'error', 'th']
False
csrf_exempt
(view_func)
Marks a view function as being exempt from the CSRF view protection.
Marks a view function as being exempt from the CSRF view protection.
def csrf_exempt(view_func): """ Marks a view function as being exempt from the CSRF view protection. """ # We could just do view_func.csrf_exempt = True, but decorators # are nicer if they don't have side-effects, so we return a new # function. def wrapped_view(*args, **kwargs): retu...
[ "def", "csrf_exempt", "(", "view_func", ")", ":", "# We could just do view_func.csrf_exempt = True, but decorators", "# are nicer if they don't have side-effects, so we return a new", "# function.", "def", "wrapped_view", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "...
[ 49, 0 ]
[ 59, 78 ]
python
en
['en', 'error', 'th']
False
ResNet.__init__
(self, args)
TODO: Write Comment
TODO: Write Comment
def __init__(self, args): """ TODO: Write Comment """ self.name = 'ResNet' CifarModel.__init__(self, args)
[ "def", "__init__", "(", "self", ",", "args", ")", ":", "self", ".", "name", "=", "'ResNet'", "CifarModel", ".", "__init__", "(", "self", ",", "args", ")" ]
[ 10, 4 ]
[ 17, 39 ]
python
en
['en', 'error', 'th']
False
ResNet.network
(self, img_input)
TODO: Write Comment
TODO: Write Comment
def network(self, img_input): """ TODO: Write Comment """ from tensorflow.keras import initializers, layers, regularizers stack_n = 5 weight_decay = 0.0001 def residual_block(img_input, out_channel,increase=False): """ TODO: Wri...
[ "def", "network", "(", "self", ",", "img_input", ")", ":", "from", "tensorflow", ".", "keras", "import", "initializers", ",", "layers", ",", "regularizers", "stack_n", "=", "5", "weight_decay", "=", "0.0001", "def", "residual_block", "(", "img_input", ",", "...
[ 19, 4 ]
[ 79, 16 ]
python
en
['en', 'error', 'th']
False
ResNet.scheduler
(self, epoch)
TODO: Write Comment
TODO: Write Comment
def scheduler(self, epoch): """ TODO: Write Comment """ if epoch < 80: return 0.1 if epoch < 150: return 0.01 return 0.001
[ "def", "scheduler", "(", "self", ",", "epoch", ")", ":", "if", "epoch", "<", "80", ":", "return", "0.1", "if", "epoch", "<", "150", ":", "return", "0.01", "return", "0.001" ]
[ 81, 4 ]
[ 90, 20 ]
python
en
['en', 'error', 'th']
False
Storage.store_vector
(self, hash_name, bucket_key, v, data)
Stores vector and JSON-serializable data in bucket with specified key.
Stores vector and JSON-serializable data in bucket with specified key.
def store_vector(self, hash_name, bucket_key, v, data): """ Stores vector and JSON-serializable data in bucket with specified key. """ raise NotImplementedError
[ "def", "store_vector", "(", "self", ",", "hash_name", ",", "bucket_key", ",", "v", ",", "data", ")", ":", "raise", "NotImplementedError" ]
[ 26, 4 ]
[ 30, 33 ]
python
en
['en', 'error', 'th']
False
Storage.store_many_vectors
(self, hash_name, bucket_keys, vs, data)
Store a batch of vectors. Stores vector and JSON-serializable data in bucket with specified key.
Store a batch of vectors. Stores vector and JSON-serializable data in bucket with specified key.
def store_many_vectors(self, hash_name, bucket_keys, vs, data): """ Store a batch of vectors. Stores vector and JSON-serializable data in bucket with specified key. """ raise NotImplementedError
[ "def", "store_many_vectors", "(", "self", ",", "hash_name", ",", "bucket_keys", ",", "vs", ",", "data", ")", ":", "raise", "NotImplementedError" ]
[ 32, 4 ]
[ 37, 33 ]
python
en
['en', 'error', 'th']
False
Storage.get_all_bucket_keys
(self, hash_name)
Returns all bucket keys for the given hash as iterable of strings
Returns all bucket keys for the given hash as iterable of strings
def get_all_bucket_keys(self, hash_name): """ Returns all bucket keys for the given hash as iterable of strings """ raise NotImplementedError
[ "def", "get_all_bucket_keys", "(", "self", ",", "hash_name", ")", ":", "raise", "NotImplementedError" ]
[ 39, 4 ]
[ 43, 33 ]
python
en
['en', 'error', 'th']
False
Storage.delete_vector
(self, hash_name, bucket_keys, data)
Deletes vector and JSON-serializable data in buckets with specified keys.
Deletes vector and JSON-serializable data in buckets with specified keys.
def delete_vector(self, hash_name, bucket_keys, data): """ Deletes vector and JSON-serializable data in buckets with specified keys. """ raise NotImplementedError
[ "def", "delete_vector", "(", "self", ",", "hash_name", ",", "bucket_keys", ",", "data", ")", ":", "raise", "NotImplementedError" ]
[ 46, 4 ]
[ 50, 33 ]
python
en
['en', 'error', 'th']
False
Storage.get_bucket
(self, hash_name, bucket_key)
Returns bucket content as list of tuples (vector, data).
Returns bucket content as list of tuples (vector, data).
def get_bucket(self, hash_name, bucket_key): """ Returns bucket content as list of tuples (vector, data). """ raise NotImplementedError
[ "def", "get_bucket", "(", "self", ",", "hash_name", ",", "bucket_key", ")", ":", "raise", "NotImplementedError" ]
[ 52, 4 ]
[ 56, 33 ]
python
en
['en', 'error', 'th']
False
Storage.clean_buckets
(self, hash_name)
Removes all buckets and their content.
Removes all buckets and their content.
def clean_buckets(self, hash_name): """ Removes all buckets and their content. """ raise NotImplementedError
[ "def", "clean_buckets", "(", "self", ",", "hash_name", ")", ":", "raise", "NotImplementedError" ]
[ 58, 4 ]
[ 62, 33 ]
python
en
['en', 'error', 'th']
False
Storage.clean_all_buckets
(self)
Removes all buckets and their content.
Removes all buckets and their content.
def clean_all_buckets(self): """ Removes all buckets and their content. """ raise NotImplementedError
[ "def", "clean_all_buckets", "(", "self", ")", ":", "raise", "NotImplementedError" ]
[ 64, 4 ]
[ 68, 33 ]
python
en
['en', 'error', 'th']
False
Storage.store_hash_configuration
(self, lshash)
Stores hash configuration
Stores hash configuration
def store_hash_configuration(self, lshash): """ Stores hash configuration """ raise NotImplementedError
[ "def", "store_hash_configuration", "(", "self", ",", "lshash", ")", ":", "raise", "NotImplementedError" ]
[ 70, 4 ]
[ 74, 33 ]
python
en
['en', 'error', 'th']
False
Storage.load_hash_configuration
(self, hash_name)
Loads and returns hash configuration
Loads and returns hash configuration
def load_hash_configuration(self, hash_name): """ Loads and returns hash configuration """ raise NotImplementedError
[ "def", "load_hash_configuration", "(", "self", ",", "hash_name", ")", ":", "raise", "NotImplementedError" ]
[ 76, 4 ]
[ 80, 33 ]
python
en
['en', 'error', 'th']
False
SourceTreeAndPathFromPath
(input_path)
Given input_path, returns a tuple with sourceTree and path values. Examples: input_path (source_tree, output_path) '$(VAR)/path' ('VAR', 'path') '$(VAR)' ('VAR', None) 'path' (None, 'path')
Given input_path, returns a tuple with sourceTree and path values.
def SourceTreeAndPathFromPath(input_path): """Given input_path, returns a tuple with sourceTree and path values. Examples: input_path (source_tree, output_path) '$(VAR)/path' ('VAR', 'path') '$(VAR)' ('VAR', None) 'path' (None, 'path') """ source_group_match = _path_lead...
[ "def", "SourceTreeAndPathFromPath", "(", "input_path", ")", ":", "source_group_match", "=", "_path_leading_variable", ".", "match", "(", "input_path", ")", "if", "source_group_match", ":", "source_tree", "=", "source_group_match", ".", "group", "(", "1", ")", "outpu...
[ 176, 0 ]
[ 194, 37 ]
python
en
['en', 'en', 'en']
True
XCObject.Copy
(self)
Make a copy of this object. The new object will have its own copy of lists and dicts. Any XCObject objects owned by this object (marked "strong") will be copied in the new object, even those found in lists. If this object has any weak references to other XCObjects, the same references are added to th...
Make a copy of this object.
def Copy(self): """Make a copy of this object. The new object will have its own copy of lists and dicts. Any XCObject objects owned by this object (marked "strong") will be copied in the new object, even those found in lists. If this object has any weak references to other XCObjects, the same...
[ "def", "Copy", "(", "self", ")", ":", "that", "=", "self", ".", "__class__", "(", "id", "=", "self", ".", "id", ",", "parent", "=", "self", ".", "parent", ")", "for", "key", ",", "value", "in", "self", ".", "_properties", ".", "items", "(", ")", ...
[ 306, 4 ]
[ 358, 19 ]
python
en
['en', 'en', 'en']
True
XCObject.Name
(self)
Return the name corresponding to an object. Not all objects necessarily need to be nameable, and not all that do have a "name" property. Override as needed.
Return the name corresponding to an object.
def Name(self): """Return the name corresponding to an object. Not all objects necessarily need to be nameable, and not all that do have a "name" property. Override as needed. """ # If the schema indicates that "name" is required, try to access the # property even if it doesn't ex...
[ "def", "Name", "(", "self", ")", ":", "# If the schema indicates that \"name\" is required, try to access the", "# property even if it doesn't exist. This will result in a KeyError", "# being raised for the property that should be present, which seems more", "# appropriate than NotImplementedErro...
[ 360, 4 ]
[ 376, 83 ]
python
en
['en', 'en', 'en']
True
XCObject.Comment
(self)
Return a comment string for the object. Most objects just use their name as the comment, but PBXProject uses different values. The returned comment is not escaped and does not have any comment marker strings applied to it.
Return a comment string for the object.
def Comment(self): """Return a comment string for the object. Most objects just use their name as the comment, but PBXProject uses different values. The returned comment is not escaped and does not have any comment marker strings applied to it. """ return self.Name()
[ "def", "Comment", "(", "self", ")", ":", "return", "self", ".", "Name", "(", ")" ]
[ 378, 4 ]
[ 388, 26 ]
python
en
['en', 'en', 'en']
True
XCObject.ComputeIDs
(self, recursive=True, overwrite=True, seed_hash=None)
Set "id" properties deterministically. An object's "id" property is set based on a hash of its class type and name, as well as the class type and name of all ancestor objects. As such, it is only advisable to call ComputeIDs once an entire project file tree is built. If recursive is True, recurse...
Set "id" properties deterministically.
def ComputeIDs(self, recursive=True, overwrite=True, seed_hash=None): """Set "id" properties deterministically. An object's "id" property is set based on a hash of its class type and name, as well as the class type and name of all ancestor objects. As such, it is only advisable to call ComputeIDs ...
[ "def", "ComputeIDs", "(", "self", ",", "recursive", "=", "True", ",", "overwrite", "=", "True", ",", "seed_hash", "=", "None", ")", ":", "def", "_HashUpdate", "(", "hash", ",", "data", ")", ":", "\"\"\"Update hash with data's length and contents.\n\n If the h...
[ 404, 4 ]
[ 464, 53 ]
python
en
['es', 'en', 'en']
True
XCObject.EnsureNoIDCollisions
(self)
Verifies that no two objects have the same ID. Checks all descendants.
Verifies that no two objects have the same ID. Checks all descendants.
def EnsureNoIDCollisions(self): """Verifies that no two objects have the same ID. Checks all descendants. """ ids = {} descendants = self.Descendants() for descendant in descendants: if descendant.id in ids: other = ids[descendant.id] rai...
[ "def", "EnsureNoIDCollisions", "(", "self", ")", ":", "ids", "=", "{", "}", "descendants", "=", "self", ".", "Descendants", "(", ")", "for", "descendant", "in", "descendants", ":", "if", "descendant", ".", "id", "in", "ids", ":", "other", "=", "ids", "...
[ 466, 4 ]
[ 484, 43 ]
python
en
['en', 'en', 'en']
True
XCObject.Children
(self)
Returns a list of all of this object's owned (strong) children.
Returns a list of all of this object's owned (strong) children.
def Children(self): """Returns a list of all of this object's owned (strong) children.""" children = [] for property, attributes in self._schema.items(): (is_list, property_type, is_strong) = attributes[0:3] if is_strong and property in self._properties: ...
[ "def", "Children", "(", "self", ")", ":", "children", "=", "[", "]", "for", "property", ",", "attributes", "in", "self", ".", "_schema", ".", "items", "(", ")", ":", "(", "is_list", ",", "property_type", ",", "is_strong", ")", "=", "attributes", "[", ...
[ 486, 4 ]
[ 497, 23 ]
python
en
['en', 'en', 'en']
True
XCObject.Descendants
(self)
Returns a list of all of this object's descendants, including this object.
Returns a list of all of this object's descendants, including this object.
def Descendants(self): """Returns a list of all of this object's descendants, including this object. """ children = self.Children() descendants = [self] for child in children: descendants.extend(child.Descendants()) return descendants
[ "def", "Descendants", "(", "self", ")", ":", "children", "=", "self", ".", "Children", "(", ")", "descendants", "=", "[", "self", "]", "for", "child", "in", "children", ":", "descendants", ".", "extend", "(", "child", ".", "Descendants", "(", ")", ")",...
[ 499, 4 ]
[ 508, 26 ]
python
en
['en', 'en', 'en']
True
XCObject._EncodeComment
(self, comment)
Encodes a comment to be placed in the project file output, mimicking Xcode behavior.
Encodes a comment to be placed in the project file output, mimicking Xcode behavior.
def _EncodeComment(self, comment): """Encodes a comment to be placed in the project file output, mimicking Xcode behavior. """ # This mimics Xcode behavior by wrapping the comment in "/*" and "*/". If # the string already contains a "*/", it is turned into "(*)/". This keeps #...
[ "def", "_EncodeComment", "(", "self", ",", "comment", ")", ":", "# This mimics Xcode behavior by wrapping the comment in \"/*\" and \"*/\". If", "# the string already contains a \"*/\", it is turned into \"(*)/\". This keeps", "# the file writer from outputting something that would be treated ...
[ 516, 4 ]
[ 527, 60 ]
python
en
['en', 'en', 'en']
True
XCObject._EncodeString
(self, value)
Encodes a string to be placed in the project file output, mimicking Xcode behavior.
Encodes a string to be placed in the project file output, mimicking Xcode behavior.
def _EncodeString(self, value): """Encodes a string to be placed in the project file output, mimicking Xcode behavior. """ # Use quotation marks when any character outside of the range A-Z, a-z, 0-9, # $ (dollar sign), . (period), and _ (underscore) is present. Also use # quota...
[ "def", "_EncodeString", "(", "self", ",", "value", ")", ":", "# Use quotation marks when any character outside of the range A-Z, a-z, 0-9,", "# $ (dollar sign), . (period), and _ (underscore) is present. Also use", "# quotation marks to represent empty strings.", "#", "# Escape \" (double-q...
[ 544, 4 ]
[ 581, 69 ]
python
en
['en', 'en', 'en']
True
XCObject._XCPrintableValue
(self, tabs, value, flatten_list=False)
Returns a representation of value that may be printed in a project file, mimicking Xcode's behavior. _XCPrintableValue can handle str and int values, XCObjects (which are made printable by returning their id property), and list and dict objects composed of any of the above types. When printing a list ...
Returns a representation of value that may be printed in a project file, mimicking Xcode's behavior.
def _XCPrintableValue(self, tabs, value, flatten_list=False): """Returns a representation of value that may be printed in a project file, mimicking Xcode's behavior. _XCPrintableValue can handle str and int values, XCObjects (which are made printable by returning their id property), and list and di...
[ "def", "_XCPrintableValue", "(", "self", ",", "tabs", ",", "value", ",", "flatten_list", "=", "False", ")", ":", "printable", "=", "\"\"", "comment", "=", "None", "if", "self", ".", "_should_print_single_line", ":", "sep", "=", "\" \"", "element_tabs", "=", ...
[ 586, 4 ]
[ 656, 24 ]
python
en
['en', 'en', 'en']
True
XCObject._XCKVPrint
(self, file, tabs, key, value)
Prints a key and value, members of an XCObject's _properties dictionary, to file. tabs is an int identifying the indentation level. If the class' _should_print_single_line variable is True, tabs is ignored and the key-value pair will be followed by a space insead of a newline.
Prints a key and value, members of an XCObject's _properties dictionary, to file.
def _XCKVPrint(self, file, tabs, key, value): """Prints a key and value, members of an XCObject's _properties dictionary, to file. tabs is an int identifying the indentation level. If the class' _should_print_single_line variable is True, tabs is ignored and the key-value pair will be followed...
[ "def", "_XCKVPrint", "(", "self", ",", "file", ",", "tabs", ",", "key", ",", "value", ")", ":", "if", "self", ".", "_should_print_single_line", ":", "printable", "=", "\"\"", "after_kv", "=", "\" \"", "else", ":", "printable", "=", "\"\\t\"", "*", "tabs"...
[ 658, 4 ]
[ 719, 41 ]
python
en
['en', 'en', 'en']
True
XCObject.Print
(self, file=sys.stdout)
Prints a reprentation of this object to file, adhering to Xcode output formatting.
Prints a reprentation of this object to file, adhering to Xcode output formatting.
def Print(self, file=sys.stdout): """Prints a reprentation of this object to file, adhering to Xcode output formatting. """ self.VerifyHasRequiredProperties() if self._should_print_single_line: # When printing an object in a single line, Xcode doesn't put any space ...
[ "def", "Print", "(", "self", ",", "file", "=", "sys", ".", "stdout", ")", ":", "self", ".", "VerifyHasRequiredProperties", "(", ")", "if", "self", ".", "_should_print_single_line", ":", "# When printing an object in a single line, Xcode doesn't put any space", "# betwee...
[ 721, 4 ]
[ 757, 45 ]
python
en
['en', 'en', 'en']
True
XCObject.UpdateProperties
(self, properties, do_copy=False)
Merge the supplied properties into the _properties dictionary. The input properties must adhere to the class schema or a KeyError or TypeError exception will be raised. If adding an object of an XCObject subclass and the schema indicates a strong relationship, the object's parent will be set to this o...
Merge the supplied properties into the _properties dictionary.
def UpdateProperties(self, properties, do_copy=False): """Merge the supplied properties into the _properties dictionary. The input properties must adhere to the class schema or a KeyError or TypeError exception will be raised. If adding an object of an XCObject subclass and the schema indicates a ...
[ "def", "UpdateProperties", "(", "self", ",", "properties", ",", "do_copy", "=", "False", ")", ":", "if", "properties", "is", "None", ":", "return", "for", "property", ",", "value", "in", "properties", ".", "items", "(", ")", ":", "# Make sure the property is...
[ 759, 4 ]
[ 861, 42 ]
python
en
['en', 'en', 'en']
True
XCObject.VerifyHasRequiredProperties
(self)
Ensure that all properties identified as required by the schema are set.
Ensure that all properties identified as required by the schema are set.
def VerifyHasRequiredProperties(self): """Ensure that all properties identified as required by the schema are set. """ # TODO(mark): A stronger verification mechanism is needed. Some # subclasses need to perform validation beyond what the schema can enforce. for property, attri...
[ "def", "VerifyHasRequiredProperties", "(", "self", ")", ":", "# TODO(mark): A stronger verification mechanism is needed. Some", "# subclasses need to perform validation beyond what the schema can enforce.", "for", "property", ",", "attributes", "in", "self", ".", "_schema", ".", "...
[ 909, 4 ]
[ 919, 81 ]
python
en
['en', 'en', 'en']
True
XCObject._SetDefaultsFromSchema
(self)
Assign object default values according to the schema. This will not overwrite properties that have already been set.
Assign object default values according to the schema. This will not overwrite properties that have already been set.
def _SetDefaultsFromSchema(self): """Assign object default values according to the schema. This will not overwrite properties that have already been set.""" defaults = {} for property, attributes in self._schema.items(): (is_list, property_type, is_strong, is_required) = attrib...
[ "def", "_SetDefaultsFromSchema", "(", "self", ")", ":", "defaults", "=", "{", "}", "for", "property", ",", "attributes", "in", "self", ".", "_schema", ".", "items", "(", ")", ":", "(", "is_list", ",", "property_type", ",", "is_strong", ",", "is_required", ...
[ 921, 4 ]
[ 940, 57 ]
python
en
['en', 'en', 'en']
True
XCHierarchicalElement.Hashables
(self)
Custom hashables for XCHierarchicalElements. XCHierarchicalElements are special. Generally, their hashes shouldn't change if the paths don't change. The normal XCObject implementation of Hashables adds a hashable for each object, which means that if the hierarchical structure changes (possibly due to...
Custom hashables for XCHierarchicalElements.
def Hashables(self): """Custom hashables for XCHierarchicalElements. XCHierarchicalElements are special. Generally, their hashes shouldn't change if the paths don't change. The normal XCObject implementation of Hashables adds a hashable for each object, which means that if the hierarchical st...
[ "def", "Hashables", "(", "self", ")", ":", "if", "self", "==", "self", ".", "PBXProjectAncestor", "(", ")", ".", "_properties", "[", "\"mainGroup\"", "]", ":", "# super", "return", "XCObject", ".", "Hashables", "(", "self", ")", "hashables", "=", "[", "]...
[ 1008, 4 ]
[ 1061, 24 ]
python
en
['en', 'en', 'en']
True
PBXGroup.AddOrGetFileByPath
(self, path, hierarchical)
Returns an existing or new file reference corresponding to path. If hierarchical is True, this method will create or use the necessary hierarchical group structure corresponding to path. Otherwise, it will look in and create an item in the current group only. If an existing matching reference is foun...
Returns an existing or new file reference corresponding to path.
def AddOrGetFileByPath(self, path, hierarchical): """Returns an existing or new file reference corresponding to path. If hierarchical is True, this method will create or use the necessary hierarchical group structure corresponding to path. Otherwise, it will look in and create an item in the curre...
[ "def", "AddOrGetFileByPath", "(", "self", ",", "path", ",", "hierarchical", ")", ":", "# Adding or getting a directory? Directories end with a trailing slash.", "is_dir", "=", "False", "if", "path", ".", "endswith", "(", "\"/\"", ")", ":", "is_dir", "=", "True", "p...
[ 1282, 4 ]
[ 1378, 13 ]
python
en
['en', 'en', 'en']
True
PBXGroup.AddOrGetVariantGroupByNameAndPath
(self, name, path)
Returns an existing or new PBXVariantGroup for name and path. If a PBXVariantGroup identified by the name and path arguments is already present as a child of this object, it is returned. Otherwise, a new PBXVariantGroup with the correct properties is created, added as a child, and returned. This ...
Returns an existing or new PBXVariantGroup for name and path.
def AddOrGetVariantGroupByNameAndPath(self, name, path): """Returns an existing or new PBXVariantGroup for name and path. If a PBXVariantGroup identified by the name and path arguments is already present as a child of this object, it is returned. Otherwise, a new PBXVariantGroup with the correct p...
[ "def", "AddOrGetVariantGroupByNameAndPath", "(", "self", ",", "name", ",", "path", ")", ":", "key", "=", "(", "name", ",", "path", ")", "if", "key", "in", "self", ".", "_variant_children_by_name_and_path", ":", "variant_group_ref", "=", "self", ".", "_variant_...
[ 1380, 4 ]
[ 1405, 32 ]
python
en
['en', 'en', 'en']
True
PBXGroup.TakeOverOnlyChild
(self, recurse=False)
If this PBXGroup has only one child and it's also a PBXGroup, take it over by making all of its children this object's children. This function will continue to take over only children when those children are groups. If there are three PBXGroups representing a, b, and c, with c inside b and b inside a,...
If this PBXGroup has only one child and it's also a PBXGroup, take it over by making all of its children this object's children.
def TakeOverOnlyChild(self, recurse=False): """If this PBXGroup has only one child and it's also a PBXGroup, take it over by making all of its children this object's children. This function will continue to take over only children when those children are groups. If there are three PBXGroups repres...
[ "def", "TakeOverOnlyChild", "(", "self", ",", "recurse", "=", "False", ")", ":", "# At this stage, check that child class types are PBXGroup exactly,", "# instead of using isinstance. The only subclass of PBXGroup,", "# PBXVariantGroup, should not participate in reparenting in the same way:...
[ 1407, 4 ]
[ 1485, 52 ]
python
en
['en', 'en', 'en']
True
XCConfigurationList.ConfigurationNamed
(self, name)
Convenience accessor to obtain an XCBuildConfiguration by name.
Convenience accessor to obtain an XCBuildConfiguration by name.
def ConfigurationNamed(self, name): """Convenience accessor to obtain an XCBuildConfiguration by name.""" for configuration in self._properties["buildConfigurations"]: if configuration._properties["name"] == name: return configuration raise KeyError(name)
[ "def", "ConfigurationNamed", "(", "self", ",", "name", ")", ":", "for", "configuration", "in", "self", ".", "_properties", "[", "\"buildConfigurations\"", "]", ":", "if", "configuration", ".", "_properties", "[", "\"name\"", "]", "==", "name", ":", "return", ...
[ 1707, 4 ]
[ 1713, 28 ]
python
en
['en', 'en', 'en']
True
XCConfigurationList.DefaultConfiguration
(self)
Convenience accessor to obtain the default XCBuildConfiguration.
Convenience accessor to obtain the default XCBuildConfiguration.
def DefaultConfiguration(self): """Convenience accessor to obtain the default XCBuildConfiguration.""" return self.ConfigurationNamed(self._properties["defaultConfigurationName"])
[ "def", "DefaultConfiguration", "(", "self", ")", ":", "return", "self", ".", "ConfigurationNamed", "(", "self", ".", "_properties", "[", "\"defaultConfigurationName\"", "]", ")" ]
[ 1715, 4 ]
[ 1717, 84 ]
python
en
['en', 'fr', 'en']
True
XCConfigurationList.HasBuildSetting
(self, key)
Determines the state of a build setting in all XCBuildConfiguration child objects. If all child objects have key in their build settings, and the value is the same in all child objects, returns 1. If no child objects have the key in their build settings, returns 0. If some, but not all, child obj...
Determines the state of a build setting in all XCBuildConfiguration child objects.
def HasBuildSetting(self, key): """Determines the state of a build setting in all XCBuildConfiguration child objects. If all child objects have key in their build settings, and the value is the same in all child objects, returns 1. If no child objects have the key in their build settings, retu...
[ "def", "HasBuildSetting", "(", "self", ",", "key", ")", ":", "has", "=", "None", "value", "=", "None", "for", "configuration", "in", "self", ".", "_properties", "[", "\"buildConfigurations\"", "]", ":", "configuration_has", "=", "configuration", ".", "HasBuild...
[ 1719, 4 ]
[ 1751, 16 ]
python
en
['en', 'en', 'en']
True
XCConfigurationList.GetBuildSetting
(self, key)
Gets the build setting for key. All child XCConfiguration objects must have the same value set for the setting, or a ValueError will be raised.
Gets the build setting for key.
def GetBuildSetting(self, key): """Gets the build setting for key. All child XCConfiguration objects must have the same value set for the setting, or a ValueError will be raised. """ # TODO(mark): This is wrong for build settings that are lists. The list # contents should be compa...
[ "def", "GetBuildSetting", "(", "self", ",", "key", ")", ":", "# TODO(mark): This is wrong for build settings that are lists. The list", "# contents should be compared (and a list copy returned?)", "value", "=", "None", "for", "configuration", "in", "self", ".", "_properties", ...
[ 1753, 4 ]
[ 1772, 20 ]
python
en
['en', 'en', 'en']
True
XCConfigurationList.SetBuildSetting
(self, key, value)
Sets the build setting for key to value in all child XCBuildConfiguration objects.
Sets the build setting for key to value in all child XCBuildConfiguration objects.
def SetBuildSetting(self, key, value): """Sets the build setting for key to value in all child XCBuildConfiguration objects. """ for configuration in self._properties["buildConfigurations"]: configuration.SetBuildSetting(key, value)
[ "def", "SetBuildSetting", "(", "self", ",", "key", ",", "value", ")", ":", "for", "configuration", "in", "self", ".", "_properties", "[", "\"buildConfigurations\"", "]", ":", "configuration", ".", "SetBuildSetting", "(", "key", ",", "value", ")" ]
[ 1774, 4 ]
[ 1780, 53 ]
python
en
['en', 'en', 'en']
True
XCConfigurationList.AppendBuildSetting
(self, key, value)
Appends value to the build setting for key, which is treated as a list, in all child XCBuildConfiguration objects.
Appends value to the build setting for key, which is treated as a list, in all child XCBuildConfiguration objects.
def AppendBuildSetting(self, key, value): """Appends value to the build setting for key, which is treated as a list, in all child XCBuildConfiguration objects. """ for configuration in self._properties["buildConfigurations"]: configuration.AppendBuildSetting(key, value)
[ "def", "AppendBuildSetting", "(", "self", ",", "key", ",", "value", ")", ":", "for", "configuration", "in", "self", ".", "_properties", "[", "\"buildConfigurations\"", "]", ":", "configuration", ".", "AppendBuildSetting", "(", "key", ",", "value", ")" ]
[ 1782, 4 ]
[ 1788, 56 ]
python
en
['en', 'en', 'en']
True
XCConfigurationList.DelBuildSetting
(self, key)
Deletes the build setting key from all child XCBuildConfiguration objects.
Deletes the build setting key from all child XCBuildConfiguration objects.
def DelBuildSetting(self, key): """Deletes the build setting key from all child XCBuildConfiguration objects. """ for configuration in self._properties["buildConfigurations"]: configuration.DelBuildSetting(key)
[ "def", "DelBuildSetting", "(", "self", ",", "key", ")", ":", "for", "configuration", "in", "self", ".", "_properties", "[", "\"buildConfigurations\"", "]", ":", "configuration", ".", "DelBuildSetting", "(", "key", ")" ]
[ 1790, 4 ]
[ 1796, 46 ]
python
en
['en', 'en', 'en']
True
XCConfigurationList.SetBaseConfiguration
(self, value)
Sets the build configuration in all child XCBuildConfiguration objects.
Sets the build configuration in all child XCBuildConfiguration objects.
def SetBaseConfiguration(self, value): """Sets the build configuration in all child XCBuildConfiguration objects. """ for configuration in self._properties["buildConfigurations"]: configuration.SetBaseConfiguration(value)
[ "def", "SetBaseConfiguration", "(", "self", ",", "value", ")", ":", "for", "configuration", "in", "self", ".", "_properties", "[", "\"buildConfigurations\"", "]", ":", "configuration", ".", "SetBaseConfiguration", "(", "value", ")" ]
[ 1798, 4 ]
[ 1803, 53 ]
python
en
['en', 'en', 'en']
True
XCBuildPhase._AddPathToDict
(self, pbxbuildfile, path)
Adds path to the dict tracking paths belonging to this build phase. If the path is already a member of this build phase, raises an exception.
Adds path to the dict tracking paths belonging to this build phase.
def _AddPathToDict(self, pbxbuildfile, path): """Adds path to the dict tracking paths belonging to this build phase. If the path is already a member of this build phase, raises an exception. """ if path in self._files_by_path: raise ValueError("Found multiple build files with path ...
[ "def", "_AddPathToDict", "(", "self", ",", "pbxbuildfile", ",", "path", ")", ":", "if", "path", "in", "self", ".", "_files_by_path", ":", "raise", "ValueError", "(", "\"Found multiple build files with path \"", "+", "path", ")", "self", ".", "_files_by_path", "[...
[ 1883, 4 ]
[ 1891, 48 ]
python
en
['en', 'en', 'en']
True
XCBuildPhase._AddBuildFileToDicts
(self, pbxbuildfile, path=None)
Maintains the _files_by_path and _files_by_xcfilelikeelement dicts. If path is specified, then it is the path that is being added to the phase, and pbxbuildfile must contain either a PBXFileReference directly referencing that path, or it must contain a PBXVariantGroup that itself contains a PBXFileRefe...
Maintains the _files_by_path and _files_by_xcfilelikeelement dicts.
def _AddBuildFileToDicts(self, pbxbuildfile, path=None): """Maintains the _files_by_path and _files_by_xcfilelikeelement dicts. If path is specified, then it is the path that is being added to the phase, and pbxbuildfile must contain either a PBXFileReference directly referencing that path, or it m...
[ "def", "_AddBuildFileToDicts", "(", "self", ",", "pbxbuildfile", ",", "path", "=", "None", ")", ":", "xcfilelikeelement", "=", "pbxbuildfile", ".", "_properties", "[", "\"fileRef\"", "]", "paths", "=", "[", "]", "if", "path", "is", "not", "None", ":", "# I...
[ 1893, 4 ]
[ 1950, 74 ]
python
en
['en', 'en', 'en']
True
PBXCopyFilesBuildPhase.SetDestination
(self, path)
Set the dstSubfolderSpec and dstPath properties from path. path may be specified in the same notation used for XCHierarchicalElements, specifically, "$(DIR)/path".
Set the dstSubfolderSpec and dstPath properties from path.
def SetDestination(self, path): """Set the dstSubfolderSpec and dstPath properties from path. path may be specified in the same notation used for XCHierarchicalElements, specifically, "$(DIR)/path". """ path_tree_match = self.path_tree_re.search(path) if path_tree_match: ...
[ "def", "SetDestination", "(", "self", ",", "path", ")", ":", "path_tree_match", "=", "self", ".", "path_tree_re", ".", "search", "(", "path", ")", "if", "path_tree_match", ":", "path_tree", "=", "path_tree_match", ".", "group", "(", "1", ")", "if", "path_t...
[ 2106, 4 ]
[ 2191, 56 ]
python
en
['en', 'en', 'en']
True
init_mp_pool
(reset=False)
Necessary because at import time, cfg might be uninitialized
Necessary because at import time, cfg might be uninitialized
def init_mp_pool(reset=False): """Necessary because at import time, cfg might be uninitialized""" global _mp_manager, _mp_pool if _mp_pool and _mp_manager and not reset: return _mp_pool cfg.CONFIG_MODIFIED = False if _mp_pool: _mp_pool.terminate() _mp_pool = None if _mp_...
[ "def", "init_mp_pool", "(", "reset", "=", "False", ")", ":", "global", "_mp_manager", ",", "_mp_pool", "if", "_mp_pool", "and", "_mp_manager", "and", "not", "reset", ":", "return", "_mp_pool", "cfg", ".", "CONFIG_MODIFIED", "=", "False", "if", "_mp_pool", ":...
[ 39, 0 ]
[ 69, 19 ]
python
en
['en', 'en', 'en']
True
reset_multiprocessing
()
Reset multiprocessing state Call this if you changed configuration parameters mid-run and need them to be re-propagated to child processes.
Reset multiprocessing state
def reset_multiprocessing(): """Reset multiprocessing state Call this if you changed configuration parameters mid-run and need them to be re-propagated to child processes. """ global _mp_pool if _mp_pool: _mp_pool.terminate() _mp_pool = None cfg.CONFIG_MODIFIED = False
[ "def", "reset_multiprocessing", "(", ")", ":", "global", "_mp_pool", "if", "_mp_pool", ":", "_mp_pool", ".", "terminate", "(", ")", "_mp_pool", "=", "None", "cfg", ".", "CONFIG_MODIFIED", "=", "False" ]
[ 111, 0 ]
[ 121, 31 ]
python
en
['de', 'en', 'en']
True
execute_entity_task
(task, gdirs, **kwargs)
Execute a task on gdirs. If you asked for multiprocessing, it will do it. If ``task`` has more arguments than `gdir` they have to be keyword arguments. Parameters ---------- task : function or sequence of functions The entity task(s) to apply. Can be None, in which case each...
Execute a task on gdirs.
def execute_entity_task(task, gdirs, **kwargs): """Execute a task on gdirs. If you asked for multiprocessing, it will do it. If ``task`` has more arguments than `gdir` they have to be keyword arguments. Parameters ---------- task : function or sequence of functions The entity tas...
[ "def", "execute_entity_task", "(", "task", ",", "gdirs", ",", "*", "*", "kwargs", ")", ":", "# Normalize task into list of tuples for simplicity", "if", "not", "isinstance", "(", "task", ",", "Sequence", ")", ":", "task", "=", "[", "task", "]", "tasks", "=", ...
[ 124, 0 ]
[ 192, 14 ]
python
en
['en', 'en', 'en']
True
execute_parallel_tasks
(gdir, tasks)
Execute a list of task on a single gdir (experimental!). This is useful when running a non-sequential list of task on a gdir, mostly for e.g. different experiments with different output files. Parameters ---------- gdir : :py:class:`oggm.GlacierDirectory` the directory to process. tas...
Execute a list of task on a single gdir (experimental!).
def execute_parallel_tasks(gdir, tasks): """Execute a list of task on a single gdir (experimental!). This is useful when running a non-sequential list of task on a gdir, mostly for e.g. different experiments with different output files. Parameters ---------- gdir : :py:class:`oggm.GlacierDirec...
[ "def", "execute_parallel_tasks", "(", "gdir", ",", "tasks", ")", ":", "pc", "=", "_pickle_copier", "(", "None", ",", "{", "}", ")", "_tasks", "=", "[", "]", "for", "task", "in", "tasks", ":", "kwargs", "=", "{", "}", "if", "isinstance", "(", "task", ...
[ 195, 0 ]
[ 231, 26 ]
python
en
['en', 'ga', 'en']
True
_check_rgi_input
(rgidf=None)
Complain if the input has duplicates.
Complain if the input has duplicates.
def _check_rgi_input(rgidf=None): """Complain if the input has duplicates.""" if rgidf is None: return # Check if dataframe or list of strs try: rgi_ids = rgidf.RGIId # if dataframe we can also check for connectivity if 'Connect' in rgidf and np.any(rgidf['Connect'] == 2...
[ "def", "_check_rgi_input", "(", "rgidf", "=", "None", ")", ":", "if", "rgidf", "is", "None", ":", "return", "# Check if dataframe or list of strs", "try", ":", "rgi_ids", "=", "rgidf", ".", "RGIId", "# if dataframe we can also check for connectivity", "if", "'Connect'...
[ 267, 0 ]
[ 285, 66 ]
python
en
['en', 'su', 'en']
True
init_glacier_regions
(rgidf=None, *, reset=False, force=False, from_prepro_level=None, prepro_border=None, prepro_rgi_version=None, prepro_base_url=None, from_tar=False, delete_tar=False)
DEPRECATED: Initializes the list of Glacier Directories for this run. This is the very first task to do (always). If the directories are already available in the working directory, use them. If not, create new ones. Parameters ---------- rgidf : GeoDataFrame or list of ids, optional for pre-comput...
DEPRECATED: Initializes the list of Glacier Directories for this run.
def init_glacier_regions(rgidf=None, *, reset=False, force=False, from_prepro_level=None, prepro_border=None, prepro_rgi_version=None, prepro_base_url=None, from_tar=False, delete_tar=False): """DEPRECATED: Initializes the list of Glacier Di...
[ "def", "init_glacier_regions", "(", "rgidf", "=", "None", ",", "*", ",", "reset", "=", "False", ",", "force", "=", "False", ",", "from_prepro_level", "=", "None", ",", "prepro_border", "=", "None", ",", "prepro_rgi_version", "=", "None", ",", "prepro_base_ur...
[ 288, 0 ]
[ 414, 16 ]
python
en
['en', 'en', 'en']
True
_isdir
(path)
os.path.isdir, returning False instead of an error on non-string/path-like objects
os.path.isdir, returning False instead of an error on non-string/path-like objects
def _isdir(path): """os.path.isdir, returning False instead of an error on non-string/path-like objects """ try: return os.path.isdir(path) except TypeError: return False
[ "def", "_isdir", "(", "path", ")", ":", "try", ":", "return", "os", ".", "path", ".", "isdir", "(", "path", ")", "except", "TypeError", ":", "return", "False" ]
[ 417, 0 ]
[ 423, 20 ]
python
en
['en', 'en', 'en']
True
init_glacier_directories
(rgidf=None, *, reset=False, force=False, from_prepro_level=None, prepro_border=None, prepro_rgi_version=None, prepro_base_url=None, from_tar=False, delete_tar=False)
Initializes the list of Glacier Directories for this run. This is the very first task to do (always). If the directories are already available in the working directory, use them. If not, create new ones. Parameters ---------- rgidf : GeoDataFrame or list of ids, optional for pre-computed runs ...
Initializes the list of Glacier Directories for this run.
def init_glacier_directories(rgidf=None, *, reset=False, force=False, from_prepro_level=None, prepro_border=None, prepro_rgi_version=None, prepro_base_url=None, from_tar=False, delete_tar=False): """Initializes the list of Glacie...
[ "def", "init_glacier_directories", "(", "rgidf", "=", "None", ",", "*", ",", "reset", "=", "False", ",", "force", "=", "False", ",", "from_prepro_level", "=", "None", ",", "prepro_border", "=", "None", ",", "prepro_rgi_version", "=", "None", ",", "prepro_bas...
[ 426, 0 ]
[ 558, 16 ]
python
en
['en', 'en', 'en']
True
gis_prepro_tasks
(gdirs)
Run all flowline preprocessing tasks on a list of glaciers. Parameters ---------- gdirs : list of :py:class:`oggm.GlacierDirectory` objects the glacier directories to process
Run all flowline preprocessing tasks on a list of glaciers.
def gis_prepro_tasks(gdirs): """Run all flowline preprocessing tasks on a list of glaciers. Parameters ---------- gdirs : list of :py:class:`oggm.GlacierDirectory` objects the glacier directories to process """ task_list = [ tasks.define_glacier_region, tasks.glacier_ma...
[ "def", "gis_prepro_tasks", "(", "gdirs", ")", ":", "task_list", "=", "[", "tasks", ".", "define_glacier_region", ",", "tasks", ".", "glacier_masks", ",", "tasks", ".", "compute_centerlines", ",", "tasks", ".", "initialize_flowlines", ",", "tasks", ".", "compute_...
[ 562, 0 ]
[ 584, 40 ]
python
en
['en', 'cy', 'en']
True
download_ref_tstars
(base_url=None)
Downloads and copies the reference list of t* to the working directory. Example url: https://cluster.klima.uni-bremen.de/~oggm/ref_mb_params/oggm_v1.4/RGIV62/CRU/centerlines/qc3/pcp2.5 Parameters ---------- base_url : str url of the params file.
Downloads and copies the reference list of t* to the working directory.
def download_ref_tstars(base_url=None): """Downloads and copies the reference list of t* to the working directory. Example url: https://cluster.klima.uni-bremen.de/~oggm/ref_mb_params/oggm_v1.4/RGIV62/CRU/centerlines/qc3/pcp2.5 Parameters ---------- base_url : str url of the params fil...
[ "def", "download_ref_tstars", "(", "base_url", "=", "None", ")", ":", "shutil", ".", "copyfile", "(", "utils", ".", "file_downloader", "(", "base_url", "+", "'/ref_tstars.csv'", ")", ",", "os", ".", "path", ".", "join", "(", "cfg", ".", "PATHS", "[", "'w...
[ 587, 0 ]
[ 601, 85 ]
python
en
['en', 'en', 'en']
True
climate_tasks
(gdirs, base_url=None)
Run all climate related entity tasks on a list of glaciers. Parameters ---------- gdirs : list of :py:class:`oggm.GlacierDirectory` objects the glacier directories to process base_url : str, optional url of the params file.
Run all climate related entity tasks on a list of glaciers.
def climate_tasks(gdirs, base_url=None): """Run all climate related entity tasks on a list of glaciers. Parameters ---------- gdirs : list of :py:class:`oggm.GlacierDirectory` objects the glacier directories to process base_url : str, optional url of the params file. """ # ...
[ "def", "climate_tasks", "(", "gdirs", ",", "base_url", "=", "None", ")", ":", "# Process climate data", "execute_entity_task", "(", "tasks", ".", "process_climate_data", ",", "gdirs", ")", "# Then, calibration?", "if", "cfg", ".", "PARAMS", "[", "'run_mb_calibration...
[ 605, 0 ]
[ 627, 57 ]
python
en
['en', 'en', 'en']
True
inversion_tasks
(gdirs, glen_a=None, fs=None, filter_inversion_output=True)
Run all ice thickness inversion tasks on a list of glaciers. Quite useful to deal with calving glaciers as well. Parameters ---------- gdirs : list of :py:class:`oggm.GlacierDirectory` objects the glacier directories to process
Run all ice thickness inversion tasks on a list of glaciers.
def inversion_tasks(gdirs, glen_a=None, fs=None, filter_inversion_output=True): """Run all ice thickness inversion tasks on a list of glaciers. Quite useful to deal with calving glaciers as well. Parameters ---------- gdirs : list of :py:class:`oggm.GlacierDirectory` objects the glacier di...
[ "def", "inversion_tasks", "(", "gdirs", ",", "glen_a", "=", "None", ",", "fs", "=", "None", ",", "filter_inversion_output", "=", "True", ")", ":", "if", "cfg", ".", "PARAMS", "[", "'use_kcalving_for_inversion'", "]", ":", "# Differentiate between calving and non-c...
[ 631, 0 ]
[ 671, 69 ]
python
en
['en', 'en', 'en']
True
calibrate_inversion_from_consensus
(gdirs, ignore_missing=True, fs=0, a_bounds=(0.1, 10), apply_fs_on_mismatch=False, error_on_mismatch=True, filter_inversion_output=True)
Fit the total volume of the glaciers to the 2019 consensus estimate. This method finds the "best Glen A" to match all glaciers in gdirs with a valid inverted volume. Parameters ---------- gdirs : list of :py:class:`oggm.GlacierDirectory` objects the glacier directories to process ignor...
Fit the total volume of the glaciers to the 2019 consensus estimate.
def calibrate_inversion_from_consensus(gdirs, ignore_missing=True, fs=0, a_bounds=(0.1, 10), apply_fs_on_mismatch=False, error_on_mismatch=True, filter_inversion_ou...
[ "def", "calibrate_inversion_from_consensus", "(", "gdirs", ",", "ignore_missing", "=", "True", ",", "fs", "=", "0", ",", "a_bounds", "=", "(", "0.1", ",", "10", ")", ",", "apply_fs_on_mismatch", "=", "False", ",", "error_on_mismatch", "=", "True", ",", "filt...
[ 675, 0 ]
[ 782, 13 ]
python
en
['en', 'en', 'en']
True
match_regional_geodetic_mb
(gdirs, rgi_reg=None, dataset='hugonnet', period='2000-01-01_2020-01-01')
Regional shift of the mass-balance residual to match observations. This is useful for operational runs, but also quite hacky. Let's hope we won't need this for too long. Parameters ---------- gdirs : the list of gdirs (ideally the entire region) rgi_reg : str the rgi region to match ...
Regional shift of the mass-balance residual to match observations.
def match_regional_geodetic_mb(gdirs, rgi_reg=None, dataset='hugonnet', period='2000-01-01_2020-01-01'): """Regional shift of the mass-balance residual to match observations. This is useful for operational runs, but also quite hacky. Let's hope we won't need this for too long...
[ "def", "match_regional_geodetic_mb", "(", "gdirs", ",", "rgi_reg", "=", "None", ",", "dataset", "=", "'hugonnet'", ",", "period", "=", "'2000-01-01_2020-01-01'", ")", ":", "# Get the mass-balance OGGM would give out of the box", "df", "=", "utils", ".", "compile_fixed_g...
[ 786, 0 ]
[ 875, 16 ]
python
en
['en', 'en', 'en']
True
match_geodetic_mb_for_selection
(gdirs, period='2000-01-01_2020-01-01', file_path=None, fail_safe=False)
Shift the mass-balance residual to match geodetic mb observations. It is similar to match_regional_geodetic_mb but uses the raw, glacier per glacier tabular data. This method finds the "best mass-balance residual" to match all glaciers in gdirs with available OGGM mass balance and available geodetic m...
Shift the mass-balance residual to match geodetic mb observations.
def match_geodetic_mb_for_selection(gdirs, period='2000-01-01_2020-01-01', file_path=None, fail_safe=False): """Shift the mass-balance residual to match geodetic mb observations. It is similar to match_regional_geodetic_mb but uses the raw, glacier per glacier tabular da...
[ "def", "match_geodetic_mb_for_selection", "(", "gdirs", ",", "period", "=", "'2000-01-01_2020-01-01'", ",", "file_path", "=", "None", ",", "fail_safe", "=", "False", ")", ":", "# Get the mass-balance OGGM would give out of the box", "df", "=", "utils", ".", "compile_fix...
[ 879, 0 ]
[ 999, 16 ]
python
en
['en', 'en', 'en']
True
merge_glacier_tasks
(gdirs, main_rgi_id=None, return_all=False, buffer=None, **kwargs)
Shortcut function: run all tasks to merge tributaries to a main glacier Parameters ---------- gdirs : list of :py:class:`oggm.GlacierDirectory` all glaciers, main and tributary. Preprocessed and initialised main_rgi_id: str RGI ID of the main glacier of interest. If None is provided mer...
Shortcut function: run all tasks to merge tributaries to a main glacier
def merge_glacier_tasks(gdirs, main_rgi_id=None, return_all=False, buffer=None, **kwargs): """Shortcut function: run all tasks to merge tributaries to a main glacier Parameters ---------- gdirs : list of :py:class:`oggm.GlacierDirectory` all glaciers, main and tributary....
[ "def", "merge_glacier_tasks", "(", "gdirs", ",", "main_rgi_id", "=", "None", ",", "return_all", "=", "False", ",", "buffer", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "len", "(", "gdirs", ")", ">", "100", ":", "raise", "InvalidParamsError", ...
[ 1003, 0 ]
[ 1062, 23 ]
python
en
['en', 'en', 'en']
True
_recursive_merging
(gdirs, gdir_main, glcdf=None, dem_source=None, filename='climate_historical', input_filesuffix='')
Recursive function to merge all tributary glaciers. This function should start with the largest glacier and then be called upon all smaller glaciers. Parameters ---------- gdirs : list of :py:class:`oggm.GlacierDirectory` all glaciers, main and tributary. Preprocessed and initialised ...
Recursive function to merge all tributary glaciers.
def _recursive_merging(gdirs, gdir_main, glcdf=None, dem_source=None, filename='climate_historical', input_filesuffix=''): """ Recursive function to merge all tributary glaciers. This function should start with the largest glacier and then be called upon all smaller glaciers. Pa...
[ "def", "_recursive_merging", "(", "gdirs", ",", "gdir_main", ",", "glcdf", "=", "None", ",", "dem_source", "=", "None", ",", "filename", "=", "'climate_historical'", ",", "input_filesuffix", "=", "''", ")", ":", "# find glaciers which intersect with the main", "trib...
[ 1065, 0 ]
[ 1123, 29 ]
python
en
['en', 'en', 'en']
True
expand_db_html
(html)
Expand database-representation HTML into proper HTML usable on front-end templates
Expand database-representation HTML into proper HTML usable on front-end templates
def expand_db_html(html): """ Expand database-representation HTML into proper HTML usable on front-end templates """ global FRONTEND_REWRITER if FRONTEND_REWRITER is None: embed_rules = features.get_embed_types() link_rules = features.get_link_types() FRONTEND_REWRITER = Mul...
[ "def", "expand_db_html", "(", "html", ")", ":", "global", "FRONTEND_REWRITER", "if", "FRONTEND_REWRITER", "is", "None", ":", "embed_rules", "=", "features", ".", "get_embed_types", "(", ")", "link_rules", "=", "features", ".", "get_link_types", "(", ")", "FRONTE...
[ 23, 0 ]
[ 37, 34 ]
python
en
['en', 'error', 'th']
False
get_text_for_indexing
(richtext)
Return a plain text version of a rich text string, suitable for search indexing; like Django's strip_tags, but ensures that whitespace is left between block elements so that <p>hello</p><p>world</p> gives "hello world", not "helloworld".
Return a plain text version of a rich text string, suitable for search indexing; like Django's strip_tags, but ensures that whitespace is left between block elements so that <p>hello</p><p>world</p> gives "hello world", not "helloworld".
def get_text_for_indexing(richtext): """ Return a plain text version of a rich text string, suitable for search indexing; like Django's strip_tags, but ensures that whitespace is left between block elements so that <p>hello</p><p>world</p> gives "hello world", not "helloworld". """ # insert spac...
[ "def", "get_text_for_indexing", "(", "richtext", ")", ":", "# insert space after </p>, </h1> - </h6>, </li> and </blockquote> tags", "richtext", "=", "re", ".", "sub", "(", "r'(</(p|h\\d|li|blockquote)>)'", ",", "r'\\1 '", ",", "richtext", ",", "flags", "=", "re", ".", ...
[ 40, 0 ]
[ 50, 49 ]
python
en
['en', 'error', 'th']
False
EntityHandler.get_model
()
If supported, returns the type of model able to be handled by this handler, e.g. Page.
If supported, returns the type of model able to be handled by this handler, e.g. Page.
def get_model(): """ If supported, returns the type of model able to be handled by this handler, e.g. Page. """ raise NotImplementedError
[ "def", "get_model", "(", ")", ":", "raise", "NotImplementedError" ]
[ 86, 4 ]
[ 90, 33 ]
python
en
['en', 'error', 'th']
False
EntityHandler.expand_db_attributes
(attrs: dict)
Given a dict of attributes from the entity tag stored in the database, returns the real HTML representation.
Given a dict of attributes from the entity tag stored in the database, returns the real HTML representation.
def expand_db_attributes(attrs: dict) -> str: """ Given a dict of attributes from the entity tag stored in the database, returns the real HTML representation. """ raise NotImplementedError
[ "def", "expand_db_attributes", "(", "attrs", ":", "dict", ")", "->", "str", ":", "raise", "NotImplementedError" ]
[ 98, 4 ]
[ 103, 33 ]
python
en
['en', 'error', 'th']
False
get_active_worker_queues
(only_test_queues: bool = False)
Returns all (either test, or real) worker queues.
Returns all (either test, or real) worker queues.
def get_active_worker_queues(only_test_queues: bool = False) -> List[str]: """Returns all (either test, or real) worker queues.""" return [ queue_name for queue_name in worker_classes.keys() if bool(queue_name in test_queues) == only_test_queues ]
[ "def", "get_active_worker_queues", "(", "only_test_queues", ":", "bool", "=", "False", ")", "->", "List", "[", "str", "]", ":", "return", "[", "queue_name", "for", "queue_name", "in", "worker_classes", ".", "keys", "(", ")", "if", "bool", "(", "queue_name", ...
[ 154, 0 ]
[ 160, 5 ]
python
en
['en', 'en', 'en']
True
LoopQueueProcessingWorker.consume
(self, event: Dict[str, Any])
In LoopQueueProcessingWorker, consume is used just for automated tests
In LoopQueueProcessingWorker, consume is used just for automated tests
def consume(self, event: Dict[str, Any]) -> None: """In LoopQueueProcessingWorker, consume is used just for automated tests""" self.consume_batch([event])
[ "def", "consume", "(", "self", ",", "event", ":", "Dict", "[", "str", ",", "Any", "]", ")", "->", "None", ":", "self", ".", "consume_batch", "(", "[", "event", "]", ")" ]
[ 407, 4 ]
[ 409, 35 ]
python
en
['en', 'en', 'en']
True
exhaust
(stream_or_iterable)
Exhaust an iterator or stream.
Exhaust an iterator or stream.
def exhaust(stream_or_iterable): """Exhaust an iterator or stream.""" try: iterator = iter(stream_or_iterable) except TypeError: iterator = ChunkIter(stream_or_iterable, 16384) for __ in iterator: pass
[ "def", "exhaust", "(", "stream_or_iterable", ")", ":", "try", ":", "iterator", "=", "iter", "(", "stream_or_iterable", ")", "except", "TypeError", ":", "iterator", "=", "ChunkIter", "(", "stream_or_iterable", ",", "16384", ")", "for", "__", "in", "iterator", ...
[ 574, 0 ]
[ 582, 12 ]
python
en
['en', 'en', 'nl']
True
parse_boundary_stream
(stream, max_header_size)
Parses one and exactly one stream that encapsulates a boundary.
Parses one and exactly one stream that encapsulates a boundary.
def parse_boundary_stream(stream, max_header_size): """ Parses one and exactly one stream that encapsulates a boundary. """ # Stream at beginning of header, look for end of header # and parse it if found. The header must fit within one # chunk. chunk = stream.read(max_header_size) # 'fi...
[ "def", "parse_boundary_stream", "(", "stream", ",", "max_header_size", ")", ":", "# Stream at beginning of header, look for end of header", "# and parse it if found. The header must fit within one", "# chunk.", "chunk", "=", "stream", ".", "read", "(", "max_header_size", ")", "...
[ 585, 0 ]
[ 641, 34 ]
python
en
['en', 'error', 'th']
False
parse_header
(line)
Parse the header into a key-value. Input (line): bytes, output: unicode for key/name, bytes for value which will be decoded later.
Parse the header into a key-value.
def parse_header(line): """ Parse the header into a key-value. Input (line): bytes, output: unicode for key/name, bytes for value which will be decoded later. """ plist = _parse_header_params(b';' + line) key = plist.pop(0).lower().decode('ascii') pdict = {} for p in plist: ...
[ "def", "parse_header", "(", "line", ")", ":", "plist", "=", "_parse_header_params", "(", "b';'", "+", "line", ")", "key", "=", "plist", ".", "pop", "(", "0", ")", ".", "lower", "(", ")", ".", "decode", "(", "'ascii'", ")", "pdict", "=", "{", "}", ...
[ 656, 0 ]
[ 688, 21 ]
python
en
['en', 'error', 'th']
False
MultiPartParser.__init__
(self, META, input_data, upload_handlers, encoding=None)
Initialize the MultiPartParser object. :META: The standard ``META`` dictionary in Django request objects. :input_data: The raw post data, as a file-like object. :upload_handlers: A list of UploadHandler instances that perform operations on the ...
Initialize the MultiPartParser object.
def __init__(self, META, input_data, upload_handlers, encoding=None): """ Initialize the MultiPartParser object. :META: The standard ``META`` dictionary in Django request objects. :input_data: The raw post data, as a file-like object. :upload_handlers: ...
[ "def", "__init__", "(", "self", ",", "META", ",", "input_data", ",", "upload_handlers", ",", "encoding", "=", "None", ")", ":", "# Content-Type should contain multipart and the boundary information.", "content_type", "=", "META", ".", "get", "(", "'CONTENT_TYPE'", ","...
[ 54, 4 ]
[ 103, 47 ]
python
en
['en', 'error', 'th']
False
MultiPartParser.parse
(self)
Parse the POST data and break it into a FILES MultiValueDict and a POST MultiValueDict. Return a tuple containing the POST and FILES dictionary, respectively.
Parse the POST data and break it into a FILES MultiValueDict and a POST MultiValueDict.
def parse(self): """ Parse the POST data and break it into a FILES MultiValueDict and a POST MultiValueDict. Return a tuple containing the POST and FILES dictionary, respectively. """ from django.http import QueryDict encoding = self._encoding handlers =...
[ "def", "parse", "(", "self", ")", ":", "from", "django", ".", "http", "import", "QueryDict", "encoding", "=", "self", ".", "_encoding", "handlers", "=", "self", ".", "_upload_handlers", "# HTTP spec says that Content-Length >= 0 is valid", "# handling content-length == ...
[ 105, 4 ]
[ 292, 38 ]
python
en
['en', 'error', 'th']
False
MultiPartParser.handle_file_complete
(self, old_field_name, counters)
Handle all the signaling that takes place when a file is complete.
Handle all the signaling that takes place when a file is complete.
def handle_file_complete(self, old_field_name, counters): """ Handle all the signaling that takes place when a file is complete. """ for i, handler in enumerate(self._upload_handlers): file_obj = handler.file_complete(counters[i]) if file_obj: # If...
[ "def", "handle_file_complete", "(", "self", ",", "old_field_name", ",", "counters", ")", ":", "for", "i", ",", "handler", "in", "enumerate", "(", "self", ".", "_upload_handlers", ")", ":", "file_obj", "=", "handler", ".", "file_complete", "(", "counters", "[...
[ 294, 4 ]
[ 303, 21 ]
python
en
['en', 'error', 'th']
False
MultiPartParser.IE_sanitize
(self, filename)
Cleanup filename from Internet Explorer full paths.
Cleanup filename from Internet Explorer full paths.
def IE_sanitize(self, filename): """Cleanup filename from Internet Explorer full paths.""" return filename and filename[filename.rfind("\\") + 1:].strip()
[ "def", "IE_sanitize", "(", "self", ",", "filename", ")", ":", "return", "filename", "and", "filename", "[", "filename", ".", "rfind", "(", "\"\\\\\"", ")", "+", "1", ":", "]", ".", "strip", "(", ")" ]
[ 305, 4 ]
[ 307, 71 ]
python
en
['en', 'en', 'en']
True
LazyStream.__init__
(self, producer, length=None)
Every LazyStream must have a producer when instantiated. A producer is an iterable that returns a string each time it is called.
Every LazyStream must have a producer when instantiated.
def __init__(self, producer, length=None): """ Every LazyStream must have a producer when instantiated. A producer is an iterable that returns a string each time it is called. """ self._producer = producer self._empty = False self._leftover = b'' ...
[ "def", "__init__", "(", "self", ",", "producer", ",", "length", "=", "None", ")", ":", "self", ".", "_producer", "=", "producer", "self", ".", "_empty", "=", "False", "self", ".", "_leftover", "=", "b''", "self", ".", "length", "=", "length", "self", ...
[ 326, 4 ]
[ 339, 32 ]
python
en
['en', 'error', 'th']
False
LazyStream.__next__
(self)
Used when the exact number of bytes to read is unimportant. This procedure just returns whatever is chunk is conveniently returned from the iterator instead. Useful to avoid unnecessary bookkeeping if performance is an issue.
Used when the exact number of bytes to read is unimportant.
def __next__(self): """ Used when the exact number of bytes to read is unimportant. This procedure just returns whatever is chunk is conveniently returned from the iterator instead. Useful to avoid unnecessary bookkeeping if performance is an issue. """ if self._...
[ "def", "__next__", "(", "self", ")", ":", "if", "self", ".", "_leftover", ":", "output", "=", "self", ".", "_leftover", "self", ".", "_leftover", "=", "b''", "else", ":", "output", "=", "next", "(", "self", ".", "_producer", ")", "self", ".", "_unget...
[ 371, 4 ]
[ 386, 21 ]
python
en
['en', 'error', 'th']
False
LazyStream.close
(self)
Used to invalidate/disable this lazy stream. Replaces the producer with an empty list. Any leftover bytes that have already been read will still be reported upon read() and/or next().
Used to invalidate/disable this lazy stream.
def close(self): """ Used to invalidate/disable this lazy stream. Replaces the producer with an empty list. Any leftover bytes that have already been read will still be reported upon read() and/or next(). """ self._producer = []
[ "def", "close", "(", "self", ")", ":", "self", ".", "_producer", "=", "[", "]" ]
[ 388, 4 ]
[ 395, 27 ]
python
en
['en', 'error', 'th']
False
LazyStream.unget
(self, bytes)
Places bytes back onto the front of the lazy stream. Future calls to read() will return those bytes first. The stream position and thus tell() will be rewound.
Places bytes back onto the front of the lazy stream.
def unget(self, bytes): """ Places bytes back onto the front of the lazy stream. Future calls to read() will return those bytes first. The stream position and thus tell() will be rewound. """ if not bytes: return self._update_unget_history(len(bytes))...
[ "def", "unget", "(", "self", ",", "bytes", ")", ":", "if", "not", "bytes", ":", "return", "self", ".", "_update_unget_history", "(", "len", "(", "bytes", ")", ")", "self", ".", "position", "-=", "len", "(", "bytes", ")", "self", ".", "_leftover", "="...
[ 400, 4 ]
[ 411, 58 ]
python
en
['en', 'error', 'th']
False
LazyStream._update_unget_history
(self, num_bytes)
Updates the unget history as a sanity check to see if we've pushed back the same number of bytes in one chunk. If we keep ungetting the same number of bytes many times (here, 50), we're mostly likely in an infinite loop of some sort. This is usually caused by a maliciously-malfo...
Updates the unget history as a sanity check to see if we've pushed back the same number of bytes in one chunk. If we keep ungetting the same number of bytes many times (here, 50), we're mostly likely in an infinite loop of some sort. This is usually caused by a maliciously-malfo...
def _update_unget_history(self, num_bytes): """ Updates the unget history as a sanity check to see if we've pushed back the same number of bytes in one chunk. If we keep ungetting the same number of bytes many times (here, 50), we're mostly likely in an infinite loop of some sort...
[ "def", "_update_unget_history", "(", "self", ",", "num_bytes", ")", ":", "self", ".", "_unget_history", "=", "[", "num_bytes", "]", "+", "self", ".", "_unget_history", "[", ":", "49", "]", "number_equal", "=", "len", "(", "[", "current_number", "for", "cur...
[ 413, 4 ]
[ 432, 13 ]
python
en
['en', 'error', 'th']
False
BoundaryIter._find_boundary
(self, data, eof=False)
Finds a multipart boundary in data. Should no boundary exist in the data None is returned instead. Otherwise a tuple containing the indices of the following are returned: * the end of current encapsulation * the start of the next encapsulation
Finds a multipart boundary in data.
def _find_boundary(self, data, eof=False): """ Finds a multipart boundary in data. Should no boundary exist in the data None is returned instead. Otherwise a tuple containing the indices of the following are returned: * the end of current encapsulation * the start of ...
[ "def", "_find_boundary", "(", "self", ",", "data", ",", "eof", "=", "False", ")", ":", "index", "=", "data", ".", "find", "(", "self", ".", "_boundary", ")", "if", "index", "<", "0", ":", "return", "None", "else", ":", "end", "=", "index", "next", ...
[ 548, 4 ]
[ 571, 28 ]
python
en
['en', 'error', 'th']
False
TestSigma.test_unweighted
(self)
Calculate unweighted mean and sample standard deviation
Calculate unweighted mean and sample standard deviation
def test_unweighted(self): """Calculate unweighted mean and sample standard deviation""" self.mean, self.sigma = sigmaclip.calcsigma(data=self.data, errors=None, mean=None) self.assertAlmostEqual(self.mean, 23.5714285714) self.assertAlmostEqual(self.sigma, 3.40867241299)
[ "def", "test_unweighted", "(", "self", ")", ":", "self", ".", "mean", ",", "self", ".", "sigma", "=", "sigmaclip", ".", "calcsigma", "(", "data", "=", "self", ".", "data", ",", "errors", "=", "None", ",", "mean", "=", "None", ")", "self", ".", "ass...
[ 18, 4 ]
[ 23, 57 ]
python
en
['en', 'en', 'en']
True
TestSigma.test_weighted
(self)
Calculate weighted mean and sample standard deviation
Calculate weighted mean and sample standard deviation
def test_weighted(self): """Calculate weighted mean and sample standard deviation""" self.mean, self.sigma = sigmaclip.calcsigma(data=self.data, errors=self.errors, mean=None) self.assertAlmostEqual(self.mean, 22.3759213759) self.assertAlmostEqual(self.sigma, 1.15495684937)
[ "def", "test_weighted", "(", "self", ")", ":", "self", ".", "mean", ",", "self", ".", "sigma", "=", "sigmaclip", ".", "calcsigma", "(", "data", "=", "self", ".", "data", ",", "errors", "=", "self", ".", "errors", ",", "mean", "=", "None", ")", "sel...
[ 25, 4 ]
[ 30, 57 ]
python
en
['en', 'en', 'en']
True