_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q12600
Client._select_next_server
train
def _select_next_server(self): """ Looks up in the server pool for an available server and attempts to connect. """ # Continue trying to connect until there is an available server # or bail in case there are no more available servers. while True: if l...
python
{ "resource": "" }
q12601
Client._close
train
def _close(self, status, do_callbacks=True): """ Takes the status on which it should leave the connection and an optional boolean parameter to dispatch the disconnected and close callbacks if there are any. """ if self.is_closed: self._status = status ...
python
{ "resource": "" }
q12602
Client.drain
train
def drain(self, sid=None): """ Drain will put a connection into a drain state. All subscriptions will immediately be put into a drain state. Upon completion, the publishers will be drained and can not publish any additional messages. Upon draining of the publishers, the connectio...
python
{ "resource": "" }
q12603
Client._process_err
train
def _process_err(self, err=None): """ Stores the last received error from the server and dispatches the error callback. """ self.stats['errors_received'] += 1 if err == "'Authorization Violation'": self._err = ErrAuthorization elif err == "'Slow Consumer'": ...
python
{ "resource": "" }
q12604
Client._read_loop
train
def _read_loop(self, data=''): """ Read loop for gathering bytes from the server in a buffer of maximum MAX_CONTROL_LINE_SIZE, then received bytes are streamed to the parsing callback for processing. """ while True: if not self.is_connected or self.is_connecti...
python
{ "resource": "" }
q12605
Client._flusher_loop
train
def _flusher_loop(self): """ Coroutine which continuously tries to consume pending commands and then flushes them to the socket. """ while True: pending = [] pending_size = 0 try: # Block and wait for the flusher to be kicked ...
python
{ "resource": "" }
q12606
Client._end_flusher_loop
train
def _end_flusher_loop(self): """ Let flusher_loop coroutine quit - useful when disconnecting. """ if not self.is_connected or self.is_connecting or self.io.closed(): if self._flush_queue is not None and self._flush_queue.empty(): self._flush_pending(check_conn...
python
{ "resource": "" }
q12607
yaml_load
train
def yaml_load(source, defaultdata=NO_DEFAULT): """merge YAML data from files found in source Always returns a dict. The YAML files are expected to contain some kind of key:value structures, possibly deeply nested. When merging, lists are appended and dict keys are replaced. The YAML files are read with...
python
{ "resource": "" }
q12608
BusinessTime.iterdays
train
def iterdays(self, d1, d2): """ Date iterator returning dates in d1 <= x < d2 """ curr = datetime.datetime.combine(d1, datetime.time()) end = datetime.datetime.combine(d2, datetime.time()) if d1.date() == d2.date(): yield curr return while ...
python
{ "resource": "" }
q12609
BusinessTime.iterweekdays
train
def iterweekdays(self, d1, d2): """ Date iterator returning dates in d1 <= x < d2, excluding weekends """ for dt in self.iterdays(d1, d2): if not self.isweekend(dt): yield dt
python
{ "resource": "" }
q12610
BusinessTime.iterbusinessdays
train
def iterbusinessdays(self, d1, d2): """ Date iterator returning dates in d1 <= x < d2, excluding weekends and holidays """ assert d2 >= d1 if d1.date() == d2.date() and d2.time() < self.business_hours[0]: return first = True for dt in self.iterdays(d1,...
python
{ "resource": "" }
q12611
BusinessTime.businesstimedelta
train
def businesstimedelta(self, d1, d2): """ Returns a datetime.timedelta with the number of full business days and business time between d1 and d2 """ if d1 > d2: d1, d2, timedelta_direction = d2, d1, -1 else: timedelta_direction = 1 business...
python
{ "resource": "" }
q12612
BusinessTime.businesstime_hours
train
def businesstime_hours(self, d1, d2): """ Returns a datetime.timedelta of business hours between d1 and d2, based on the length of the businessday """ open_hours = self.open_hours.seconds / 3600 btd = self.businesstimedelta(d1, d2) btd_hours = btd.seconds / 3600 ...
python
{ "resource": "" }
q12613
USFederalHolidays._day_rule_matches
train
def _day_rule_matches(self, rule, dt): """ Day-of-month-specific US federal holidays that fall on Sat or Sun are observed on Fri or Mon respectively. Note that this method considers both the actual holiday and the day of observance to be holidays. """ if dt.weekday() == 4...
python
{ "resource": "" }
q12614
PickleShareDB.hcompress
train
def hcompress(self, hashroot): """ Compress category 'hashroot', so hset is fast again hget will fail if fast_only is True for compressed items (that were hset before hcompress). """ hfiles = self.keys(hashroot + "/*") all = {} for f in hfiles: # pri...
python
{ "resource": "" }
q12615
PickleShareDB.keys
train
def keys(self, globpat = None): """ All keys in DB, or all keys matching a glob""" if globpat is None: files = self.root.rglob('*') else: files = self.root.glob(globpat) return [self._normalized(p) for p in files if p.is_file()]
python
{ "resource": "" }
q12616
PickleShareDB.uncache
train
def uncache(self,*items): """ Removes all, or specified items from cache Use this after reading a large amount of large objects to free up memory, when you won't be needing the objects for a while. """ if not items: self.cache = {} for it in items: ...
python
{ "resource": "" }
q12617
hacking_has_only_comments
train
def hacking_has_only_comments(physical_line, filename, lines, line_number): """Check for empty files with only comments H104 empty file with only comments """ if line_number == 1 and all(map(EMPTY_LINE_RE.match, lines)): return (0, "H104: File contains nothing but comments")
python
{ "resource": "" }
q12618
_project_is_apache
train
def _project_is_apache(): """Determine if a project is Apache. Look for a key string in a set of possible license files to figure out if a project looks to be Apache. This is used as a precondition for enforcing license headers. """ global _is_apache_cache if _is_apache_cache is not None: ...
python
{ "resource": "" }
q12619
_check_for_exact_apache
train
def _check_for_exact_apache(start, lines): """Check for the Apache 2.0 license header. We strip all the newlines and extra spaces so this license string should work regardless of indentation in the file. """ APACHE2 = """ Licensed under the Apache License, Version 2.0 (the "License"); you may not u...
python
{ "resource": "" }
q12620
hacking_no_author_tags
train
def hacking_no_author_tags(physical_line): """Check that no author tags are used. H105 don't use author tags """ for regex in AUTHOR_TAG_RE: if regex.match(physical_line): physical_line = physical_line.lower() pos = physical_line.find('moduleauthor') if pos <...
python
{ "resource": "" }
q12621
hacking_python3x_except_compatible
train
def hacking_python3x_except_compatible(logical_line, noqa): r"""Check for except statements to be Python 3.x compatible As of Python 3.x, the construct 'except x,y:' has been removed. Use 'except x as y:' instead. Okay: try:\n pass\nexcept Exception:\n pass Okay: try:\n pass\nexcept (Exc...
python
{ "resource": "" }
q12622
hacking_python3x_octal_literals
train
def hacking_python3x_octal_literals(logical_line, tokens, noqa): r"""Check for octal literals in Python 3.x compatible form. As of Python 3.x, the construct "0755" has been removed. Use "0o755" instead". Okay: f(0o755) Okay: 'f(0755)' Okay: f(755) Okay: f(0) Okay: f(000) Okay: MiB...
python
{ "resource": "" }
q12623
hacking_python3x_print_function
train
def hacking_python3x_print_function(logical_line, noqa): r"""Check that all print occurrences look like print functions. Check that all occurrences of print look like functions, not print operator. As of Python 3.x, the print operator has been removed. Okay: print(msg) Okay: print (msg) O...
python
{ "resource": "" }
q12624
hacking_python3x_metaclass
train
def hacking_python3x_metaclass(logical_line, noqa): r"""Check for metaclass to be Python 3.x compatible. Okay: @six.add_metaclass(Meta)\nclass Foo(object):\n pass Okay: @six.with_metaclass(Meta)\nclass Foo(object):\n pass Okay: class Foo(object):\n '''docstring\n\n __metaclass__ = Meta\n'''...
python
{ "resource": "" }
q12625
hacking_no_removed_module
train
def hacking_no_removed_module(logical_line, noqa): r"""Check for removed modules in Python 3. Examples: Okay: from os import path Okay: from os import path as p Okay: from os import (path as p) Okay: import os.path H237: import thread Okay: import thread # noqa H237: import command...
python
{ "resource": "" }
q12626
hacking_no_old_style_class
train
def hacking_no_old_style_class(logical_line, noqa): r"""Check for old style classes. Examples: Okay: class Foo(object):\n pass Okay: class Foo(Bar, Baz):\n pass Okay: class Foo(object, Baz):\n pass Okay: class Foo(somefunc()):\n pass H238: class Bar:\n pass H238: class Ba...
python
{ "resource": "" }
q12627
no_vim_headers
train
def no_vim_headers(physical_line, line_number, lines): r"""Check for vim editor configuration in source files. By default vim modelines can only appear in the first or last 5 lines of a source file. Examples: H106: # vim: set tabstop=4 shiftwidth=4\n#\n#\n#\n#\n# H106: # Lic\n# vim: set tabsto...
python
{ "resource": "" }
q12628
hacking_import_rules
train
def hacking_import_rules(logical_line, filename, noqa): r"""Check for imports. OpenStack HACKING guide recommends one import per line: Do not import more than one module per line Examples: Okay: from nova.compute import api H301: from nova.compute import api, utils Do not use wildcard im...
python
{ "resource": "" }
q12629
hacking_import_alphabetical
train
def hacking_import_alphabetical(logical_line, blank_before, previous_logical, indent_level, previous_indent_level): r"""Check for imports in alphabetical order. OpenStack HACKING guide recommendation for imports: imports in human alphabetical order Okay: import os\nimpo...
python
{ "resource": "" }
q12630
is_import_exception
train
def is_import_exception(mod): """Check module name to see if import has been whitelisted. Import based rules should not run on any whitelisted module """ return (mod in IMPORT_EXCEPTIONS or any(mod.startswith(m + '.') for m in IMPORT_EXCEPTIONS))
python
{ "resource": "" }
q12631
hacking_docstring_start_space
train
def hacking_docstring_start_space(physical_line, previous_logical, tokens): r"""Check for docstring not starting with space. OpenStack HACKING guide recommendation for docstring: Docstring should not start with space Okay: def foo():\n '''This is good.''' Okay: def foo():\n r'''This is good....
python
{ "resource": "" }
q12632
hacking_docstring_multiline_end
train
def hacking_docstring_multiline_end(physical_line, previous_logical, tokens): r"""Check multi line docstring end. OpenStack HACKING guide recommendation for docstring: Docstring should end on a new line Okay: '''foobar\nfoo\nbar\n''' Okay: def foo():\n '''foobar\n\nfoo\nbar\n''' Okay: class...
python
{ "resource": "" }
q12633
hacking_docstring_multiline_start
train
def hacking_docstring_multiline_start(physical_line, previous_logical, tokens): r"""Check multi line docstring starts immediately with summary. OpenStack HACKING guide recommendation for docstring: Docstring should start with a one-line summary, less than 80 characters. Okay: '''foobar\n\nfoo\nbar\n''...
python
{ "resource": "" }
q12634
hacking_docstring_summary
train
def hacking_docstring_summary(physical_line, previous_logical, tokens): r"""Check multi line docstring summary is separated with empty line. OpenStack HACKING guide recommendation for docstring: Docstring should start with a one-line summary, less than 80 characters. Okay: def foo():\n a = '''\nnot...
python
{ "resource": "" }
q12635
is_docstring
train
def is_docstring(tokens, previous_logical): """Return found docstring 'A docstring is a string literal that occurs as the first statement in a module, function, class,' http://www.python.org/dev/peps/pep-0257/#what-is-a-docstring """ for token_type, text, start, _, _ in tokens: if token...
python
{ "resource": "" }
q12636
_find_first_of
train
def _find_first_of(line, substrings): """Find earliest occurrence of one of substrings in line. Returns pair of index and found substring, or (-1, None) if no occurrences of any of substrings were found in line. """ starts = ((line.find(i), i) for i in substrings) found = [(i, sub) for i, sub i...
python
{ "resource": "" }
q12637
check_i18n
train
def check_i18n(): """Generator that checks token stream for localization errors. Expects tokens to be ``send``ed one by one. Raises LocalizationError if some error is found. """ while True: try: token_type, text, _, _, line = yield except GeneratorExit: retur...
python
{ "resource": "" }
q12638
hacking_localization_strings
train
def hacking_localization_strings(logical_line, tokens, noqa): r"""Check localization in line. Okay: _("This is fine") Okay: _LI("This is fine") Okay: _LW("This is fine") Okay: _LE("This is fine") Okay: _LC("This is fine") Okay: _("This is also fine %s") Okay: _("So is this %s, %(foo)s")...
python
{ "resource": "" }
q12639
is_none
train
def is_none(node): '''Check whether an AST node corresponds to None. In Python 2 None uses the same ast.Name class that variables etc. use, but in Python 3 there is a new ast.NameConstant class. ''' if PY2: return isinstance(node, ast.Name) and node.id == 'None' return isinstance(node, ...
python
{ "resource": "" }
q12640
hacking_assert_equal
train
def hacking_assert_equal(logical_line, noqa): r"""Check that self.assertEqual and self.assertNotEqual are used. Okay: self.assertEqual(x, y) Okay: self.assertNotEqual(x, y) H204: self.assertTrue(x == y) H204: self.assertTrue(x != y) H204: self.assertFalse(x == y) H204: self.assertFalse(x !=...
python
{ "resource": "" }
q12641
hacking_no_cr
train
def hacking_no_cr(physical_line): r"""Check that we only use newlines not carriage returns. Okay: import os\nimport sys # pep8 doesn't yet replace \r in strings, will work on an # upstream fix H903 import os\r\nimport sys """ pos = physical_line.find('\r') if pos != -1 and pos == (len(p...
python
{ "resource": "" }
q12642
PaginatedDatasetResults.count
train
def count(self, count): """ Sets the count of this PaginatedDatasetResults. :param count: The count of this PaginatedDatasetResults. :type: int """ if count is None: raise ValueError("Invalid value for `count`, must not be `None`") if count is not Non...
python
{ "resource": "" }
q12643
WebAuthorization.type
train
def type(self, type): """ Sets the type of this WebAuthorization. The authorization scheme. Usually this is \"Bearer\" but it could be other values like \"Token\" or \"Basic\" etc. :param type: The type of this WebAuthorization. :type: str """ if type is None: ...
python
{ "resource": "" }
q12644
LocalDataset.describe
train
def describe(self, resource=None): """Describe dataset or resource within dataset :param resource: The name of a specific resource (i.e. file or table) contained in the dataset. If ``resource`` is None, this method will describe the dataset itself. (Default value = None) ...
python
{ "resource": "" }
q12645
LocalDataset._load_raw_data
train
def _load_raw_data(self, resource_name): """Extract raw data from resource :param resource_name: """ # Instantiating the resource again as a simple `Resource` ensures that # ``data`` will be returned as bytes. upcast_resource = datapackage.Resource( self.__re...
python
{ "resource": "" }
q12646
LocalDataset._load_table
train
def _load_table(self, resource_name): """Build table structure from resource data :param resource_name: """ tabular_resource = self.__tabular_resources[resource_name] try: # Sorting fields in the same order as they appear in the schema # is necessary for...
python
{ "resource": "" }
q12647
LocalDataset._load_dataframe
train
def _load_dataframe(self, resource_name): """Build pandas.DataFrame from resource data Lazy load any optional dependencies in order to allow users to use package without installing pandas if so they wish. :param resource_name: """ try: import pandas ...
python
{ "resource": "" }
q12648
DatasetPatchRequest.visibility
train
def visibility(self, visibility): """ Sets the visibility of this DatasetPatchRequest. Dataset visibility. `OPEN` if the dataset can be seen by any member of data.world. `PRIVATE` if the dataset can be seen by its owner and authorized collaborators. :param visibility: The visibility of ...
python
{ "resource": "" }
q12649
ProjectPutRequest.objective
train
def objective(self, objective): """ Sets the objective of this ProjectPutRequest. Short project objective. :param objective: The objective of this ProjectPutRequest. :type: str """ if objective is not None and len(objective) > 120: raise ValueError("I...
python
{ "resource": "" }
q12650
QueryResults.table
train
def table(self): """Build and cache a table from query results""" if self._table is None: self._table = list(self._iter_rows()) return self._table
python
{ "resource": "" }
q12651
QueryResults.dataframe
train
def dataframe(self): """Build and cache a dataframe from query results""" if self._dataframe is None: try: import pandas as pd except ImportError: raise RuntimeError('To enable dataframe support, ' 'run \'pip ins...
python
{ "resource": "" }
q12652
fields_to_dtypes
train
def fields_to_dtypes(schema): """Maps table schema fields types to dtypes separating date fields :param schema: """ datetime_types = ['date', 'datetime'] datetime_fields = { f['name']: _TABLE_SCHEMA_DTYPE_MAPPING.get(f['type'], 'object') for f in schema['fields'] if f['type'...
python
{ "resource": "" }
q12653
sanitize_resource_schema
train
def sanitize_resource_schema(r): """Sanitize table schema for increased compatibility Up to version 0.9.0 jsontableschema did not support year, yearmonth and duration field types https://github.com/frictionlessdata/jsontableschema-py/pull/152 :param r: """ if 'schema' in r.descriptor: ...
python
{ "resource": "" }
q12654
infer_table_schema
train
def infer_table_schema(sparql_results_json): """Infer Table Schema from SPARQL results JSON SPARQL JSON Results Spec: https://www.w3.org/TR/2013/REC-sparql11-results-json-20130321 :param sparql_results_json: SPARQL JSON results of a query :returns: A schema descriptor for the inferred schema :...
python
{ "resource": "" }
q12655
order_columns_in_row
train
def order_columns_in_row(fields, unordered_row): """Ensure columns appear in the same order for every row in table :param fields: :param unordered_row: """ fields_idx = {f: pos for pos, f in enumerate(fields)} return OrderedDict(sorted(unordered_row.items(), key=la...
python
{ "resource": "" }
q12656
_get_types_from_sample
train
def _get_types_from_sample(result_vars, sparql_results_json): """Return types if homogenous within sample Compare up to 10 rows of results to determine homogeneity. DESCRIBE and CONSTRUCT queries, for example, :param result_vars: :param sparql_results_json: """ total_bindings = len(sparql...
python
{ "resource": "" }
q12657
FileConfig.save
train
def save(self): """Persist config changes""" with open(self._config_file_path, 'w') as file: self._config_parser.write(file)
python
{ "resource": "" }
q12658
ChainedConfig._first_not_none
train
def _first_not_none(seq, supplier_func): """Applies supplier_func to each element in seq, returns 1st not None :param seq: Sequence of object :type seq: iterable :param supplier_func: Function that extracts the desired value from elements in seq :type supplier_func: ...
python
{ "resource": "" }
q12659
cli
train
def cli(ctx, profile): """dw commands support working with multiple data.world accounts \b Use a different <profile> value for each account. In the absence of a <profile>, 'default' will be used. """ if ctx.obj is None: ctx.obj = {} ctx.obj['profile'] = profile pass
python
{ "resource": "" }
q12660
configure
train
def configure(obj, token): """Use this command to configure API tokens """ config = obj.get('config') or FileConfig(obj['profile']) config.auth_token = token config.save()
python
{ "resource": "" }
q12661
FileSourceCreateOrUpdateRequest.request_entity
train
def request_entity(self, request_entity): """ Sets the request_entity of this FileSourceCreateOrUpdateRequest. :param request_entity: The request_entity of this FileSourceCreateOrUpdateRequest. :type: str """ if request_entity is not None and len(request_entity) > 10000:...
python
{ "resource": "" }
q12662
InsightPutRequest.title
train
def title(self, title): """ Sets the title of this InsightPutRequest. Insight title. :param title: The title of this InsightPutRequest. :type: str """ if title is None: raise ValueError("Invalid value for `title`, must not be `None`") if title...
python
{ "resource": "" }
q12663
RestApiClient.get_dataset
train
def get_dataset(self, dataset_key): """Retrieve an existing dataset definition This method retrieves metadata about an existing :param dataset_key: Dataset identifier, in the form of owner/id :type dataset_key: str :returns: Dataset definition, with all attributes :rtyp...
python
{ "resource": "" }
q12664
RestApiClient.create_dataset
train
def create_dataset(self, owner_id, **kwargs): """Create a new dataset :param owner_id: Username of the owner of the new dataset :type owner_id: str :param title: Dataset title (will be used to generate dataset id on creation) :type title: str :param descripti...
python
{ "resource": "" }
q12665
RestApiClient.replace_dataset
train
def replace_dataset(self, dataset_key, **kwargs): """Replace an existing dataset *This method will completely overwrite an existing dataset.* :param description: Dataset description :type description: str, optional :param summary: Dataset summary markdown :type summary:...
python
{ "resource": "" }
q12666
RestApiClient.delete_dataset
train
def delete_dataset(self, dataset_key): """Deletes a dataset and all associated data :params dataset_key: Dataset identifier, in the form of owner/id :type dataset_key: str :raises RestApiException: If a server error occurs Examples -------- >>> import datadotwor...
python
{ "resource": "" }
q12667
RestApiClient.add_files_via_url
train
def add_files_via_url(self, dataset_key, files={}): """Add or update dataset files linked to source URLs :param dataset_key: Dataset identifier, in the form of owner/id :type dataset_key: str :param files: Dict containing the name of files and metadata Uses file name as a di...
python
{ "resource": "" }
q12668
RestApiClient.sync_files
train
def sync_files(self, dataset_key): """Trigger synchronization process to update all dataset files linked to source URLs. :param dataset_key: Dataset identifier, in the form of owner/id :type dataset_key: str :raises RestApiException: If a server error occurs Examples ...
python
{ "resource": "" }
q12669
RestApiClient.upload_files
train
def upload_files(self, dataset_key, files, files_metadata={}, **kwargs): """Upload dataset files :param dataset_key: Dataset identifier, in the form of owner/id :type dataset_key: str :param files: The list of names/paths for files stored in the local filesystem :type fi...
python
{ "resource": "" }
q12670
RestApiClient.upload_file
train
def upload_file(self, dataset_key, name, file_metadata={}, **kwargs): """Upload one file to a dataset :param dataset_key: Dataset identifier, in the form of owner/id :type dataset_key: str :param name: Name/path for files stored in the local filesystem :type name: str :p...
python
{ "resource": "" }
q12671
RestApiClient.download_datapackage
train
def download_datapackage(self, dataset_key, dest_dir): """Download and unzip a dataset's datapackage :param dataset_key: Dataset identifier, in the form of owner/id :type dataset_key: str :param dest_dir: Directory under which datapackage should be saved :type dest_dir: str or p...
python
{ "resource": "" }
q12672
RestApiClient.get_user_data
train
def get_user_data(self): """Retrieve data for authenticated user :returns: User data, with all attributes :rtype: dict :raises RestApiException: If a server error occurs Examples -------- >>> import datadotworld as dw >>> api_client = dw.api_client() ...
python
{ "resource": "" }
q12673
RestApiClient.fetch_contributing_projects
train
def fetch_contributing_projects(self, **kwargs): """Fetch projects that the currently authenticated user has access to :returns: Authenticated user projects :rtype: dict :raises RestApiException: If a server error occurs Examples -------- >>> import datadotworld...
python
{ "resource": "" }
q12674
RestApiClient.sql
train
def sql(self, dataset_key, query, desired_mimetype='application/json', **kwargs): """Executes SQL queries against a dataset via POST :param dataset_key: Dataset identifier, in the form of owner/id :type dataset_key: str :param query: SQL query :type query: str ...
python
{ "resource": "" }
q12675
RestApiClient.sparql
train
def sparql(self, dataset_key, query, desired_mimetype='application/sparql-results+json', **kwargs): """Executes SPARQL queries against a dataset via POST :param dataset_key: Dataset identifier, in the form of owner/id :type dataset_key: str :param query: SPARQL query ...
python
{ "resource": "" }
q12676
RestApiClient.download_dataset
train
def download_dataset(self, dataset_key): """Return a .zip containing all files within the dataset as uploaded. :param dataset_key : Dataset identifier, in the form of owner/id :type dataset_key: str :returns: .zip file contain files within dataset :rtype: file object :ra...
python
{ "resource": "" }
q12677
RestApiClient.append_records
train
def append_records(self, dataset_key, stream_id, body): """Append records to a stream. :param dataset_key: Dataset identifier, in the form of owner/id :type dataset_key: str :param stream_id: Stream unique identifier. :type stream_id: str :param body: Object body ...
python
{ "resource": "" }
q12678
RestApiClient.get_project
train
def get_project(self, project_key): """Retrieve an existing project This method retrieves metadata about an existing project :param project_key: Project identifier, in the form of owner/id :type project_key: str :returns: Project definition, with all attributes :rtype: ...
python
{ "resource": "" }
q12679
RestApiClient.update_project
train
def update_project(self, project_key, **kwargs): """Update an existing project :param project_key: Username and unique identifier of the creator of a project in the form of owner/id. :type project_key: str :param title: Project title :type title: str :param o...
python
{ "resource": "" }
q12680
RestApiClient.replace_project
train
def replace_project(self, project_key, **kwargs): """Replace an existing Project *Create a project with a given id or completely rewrite the project, including any previously added files or linked datasets, if one already exists with the given id.* :param project_key: Username ...
python
{ "resource": "" }
q12681
RestApiClient.add_linked_dataset
train
def add_linked_dataset(self, project_key, dataset_key): """Link project to an existing dataset This method links a dataset to project :param project_key: Project identifier, in the form of owner/id :type project_key: str :param dataset_key: Dataset identifier, in the form of ow...
python
{ "resource": "" }
q12682
RestApiClient.get_insight
train
def get_insight(self, project_key, insight_id, **kwargs): """Retrieve an insight :param project_key: Project identifier, in the form of projectOwner/projectid :type project_key: str :param insight_id: Insight unique identifier. :type insight_id: str :returns: Ins...
python
{ "resource": "" }
q12683
RestApiClient.get_insights_for_project
train
def get_insights_for_project(self, project_key, **kwargs): """Get insights for a project. :param project_key: Project identifier, in the form of projectOwner/projectid :type project_key: str :returns: Insight results :rtype: object :raises RestApiException: If a ...
python
{ "resource": "" }
q12684
RestApiClient.create_insight
train
def create_insight(self, project_key, **kwargs): """Create a new insight :param project_key: Project identifier, in the form of projectOwner/projectid :type project_key: str :param title: Insight title :type title: str :param description: Insight description. ...
python
{ "resource": "" }
q12685
RestApiClient.replace_insight
train
def replace_insight(self, project_key, insight_id, **kwargs): """Replace an insight. :param project_key: Projrct identifier, in the form of projectOwner/projectid :type project_key: str :param insight_id: Insight unique identifier. :type insight_id: str :param ti...
python
{ "resource": "" }
q12686
RestApiClient.update_insight
train
def update_insight(self, project_key, insight_id, **kwargs): """Update an insight. **Note that only elements included in the request will be updated. All omitted elements will remain untouched. :param project_key: Projrct identifier, in the form of projectOwner/projectid ...
python
{ "resource": "" }
q12687
RestApiClient.delete_insight
train
def delete_insight(self, project_key, insight_id): """Delete an existing insight. :params project_key: Project identifier, in the form of projectOwner/projectId :type project_key: str :params insight_id: Insight unique id :type insight_id: str :raises RestApiExce...
python
{ "resource": "" }
q12688
parse_dataset_key
train
def parse_dataset_key(dataset_key): """Parse a dataset URL or path and return the owner and the dataset id :param dataset_key: Dataset key (in the form of owner/id) or dataset URL :type dataset_key: str :returns: User name of the dataset owner and ID of the dataset :rtype: dataset_owner, dataset_id...
python
{ "resource": "" }
q12689
LazyLoadedDict.from_keys
train
def from_keys(cls, keys, loader_func, type_hint=None): """Factory method for `LazyLoadedDict` Accepts a ``loader_func`` that is to be applied to all ``keys``. :param keys: List of keys to create the dictionary with :type keys: iterable :param loader_func: Function to be applied...
python
{ "resource": "" }
q12690
FileCreateOrUpdateRequest.name
train
def name(self, name): """ Sets the name of this FileCreateOrUpdateRequest. File name. Should include type extension always when possible. Must not include slashes. :param name: The name of this FileCreateOrUpdateRequest. :type: str """ if name is None: ...
python
{ "resource": "" }
q12691
FileCreateOrUpdateRequest.labels
train
def labels(self, labels): """ Sets the labels of this FileCreateOrUpdateRequest. File labels. :param labels: The labels of this FileCreateOrUpdateRequest. :type: list[str] """ allowed_values = ["raw data", "documentation", "visualization", "clean data", "script",...
python
{ "resource": "" }
q12692
WebCredentials.user
train
def user(self, user): """ Sets the user of this WebCredentials. The name of the account to login to. :param user: The user of this WebCredentials. :type: str """ if user is None: raise ValueError("Invalid value for `user`, must not be `None`") ...
python
{ "resource": "" }
q12693
OauthTokenReference.owner
train
def owner(self, owner): """ Sets the owner of this OauthTokenReference. User name of the owner of the OAuth token within data.world. :param owner: The owner of this OauthTokenReference. :type: str """ if owner is None: raise ValueError("Invalid value ...
python
{ "resource": "" }
q12694
OauthTokenReference.site
train
def site(self, site): """ Sets the site of this OauthTokenReference. :param site: The site of this OauthTokenReference. :type: str """ if site is None: raise ValueError("Invalid value for `site`, must not be `None`") if site is not None and len(site) ...
python
{ "resource": "" }
q12695
FileSourceCreateRequest.url
train
def url(self, url): """ Sets the url of this FileSourceCreateRequest. Source URL of file. Must be an http, https. :param url: The url of this FileSourceCreateRequest. :type: str """ if url is None: raise ValueError("Invalid value for `url`, must not b...
python
{ "resource": "" }
q12696
LinkedDatasetCreateOrUpdateRequest.owner
train
def owner(self, owner): """ Sets the owner of this LinkedDatasetCreateOrUpdateRequest. User name and unique identifier of the creator of the dataset. :param owner: The owner of this LinkedDatasetCreateOrUpdateRequest. :type: str """ if owner is None: ...
python
{ "resource": "" }
q12697
RemoteFile.read
train
def read(self): """read the contents of the file that's been opened in read mode""" if 'r' == self._mode: return self._read_response.text elif 'rb' == self._mode: return self._read_response.content else: raise IOError("File not opened in read mode.")
python
{ "resource": "" }
q12698
RemoteFile._open_for_read
train
def _open_for_read(self): """open the file in read mode""" ownerid, datasetid = parse_dataset_key(self._dataset_key) response = requests.get( '{}/file_download/{}/{}/{}'.format( self._query_host, ownerid, datasetid, self._file_name), headers={ ...
python
{ "resource": "" }
q12699
RemoteFile._open_for_write
train
def _open_for_write(self): """open the file in write mode""" def put_request(body): """ :param body: """ ownerid, datasetid = parse_dataset_key(self._dataset_key) response = requests.put( "{}/uploads/{}/{}/files/{}".format( ...
python
{ "resource": "" }