code string | signature string | docstring string | loss_without_docstring float64 | loss_with_docstring float64 | factor float64 |
|---|---|---|---|---|---|
asset_location = re.match(r'^/?(static)?/?(.*)', element[attr],
re.IGNORECASE)
# replace relative links i.e (../../static)
asset_location = asset_location.group(2).replace('../', '')
return asset_location | def get_asset_location(element, attr) | Get Asset Location.
Remove leading slash e.g '/static/images.jpg' ==> static/images.jpg
Also, if the url is also prefixed with static, it would be removed.
e.g static/image.jpg ==> image.jpg | 7.097698 | 6.302239 | 1.126218 |
transformed = []
namespace = namespace + '/' if namespace else ''
for attribute, elements in matches:
for element in elements:
asset_location = get_asset_location(element, attribute)
# string substitution
sub_dict = {
'static_endpoint': stat... | def transform(matches, framework, namespace, static_endpoint) | The actual transformation occurs here.
flask example: images/staticfy.jpg', ==>
"{{ url_for('static', filename='images/staticfy.jpg') }}" | 4.901358 | 5.603629 | 0.874676 |
with open(html_file) as f:
document = BeautifulSoup(f, 'html.parser')
def condition(tag, attr):
# Don't include external links
return lambda x: x.name == tag \
and not x.get(attr, 'http').startswith(('http', '//'))
all_tags = [(attr, document.fi... | def get_elements(html_file, tags) | Extract all the elements we're interested in.
Returns a list of tuples with the attribute as first item
and the list of elements as the second item. | 4.634579 | 4.361392 | 1.062638 |
result = []
with codecs.open(html_file, 'r', 'utf-8') as input_file:
for line in input_file:
# replace all single quotes with double quotes
line = re.sub(r'\'', '"', line)
for attr, value, new_link in transformed:
if attr in line and value in lin... | def replace_lines(html_file, transformed) | Replace lines in the old file with the transformed lines. | 3.360537 | 3.343463 | 1.005107 |
# unpack arguments
static_endpoint = args.static_endpoint or 'static'
framework = args.framework or os.getenv('STATICFY_FRAMEWORK', 'flask')
add_tags = args.add_tags or {}
exc_tags = args.exc_tags or {}
namespace = args.namespace or {}
# default tags
tags = {('img', 'src'), ('link'... | def staticfy(html_file, args=argparse.ArgumentParser()) | Staticfy method.
Loop through each line of the file and replaces the old links | 4.149564 | 3.883677 | 1.068463 |
destination = args.o or args.output
if destination:
with open(destination, 'w') as file:
file.write(staticfied)
else:
print(staticfied) | def file_ops(staticfied, args) | Write to stdout or a file | 3.300936 | 3.104182 | 1.063384 |
parser = argparse.ArgumentParser()
parser.add_argument('file', type=str,
help='Filename to be staticfied')
parser.add_argument('--static-endpoint',
help='Static endpoint which is "static" by default')
parser.add_argument('--add-tags', type=str,
... | def parse_cmd_arguments() | Parse command line arguments. | 3.832029 | 3.7296 | 1.027464 |
args = parse_cmd_arguments()
html_file = args.file
try:
json.loads(args.add_tags or '{}')
json.loads(args.exc_tags or '{}')
except ValueError:
print('\033[91m' + 'Invalid json string: please provide a valid json '
'string e.g {}'.format('\'{"img": "data-url"}\... | def main() | Main method. | 5.982383 | 5.898979 | 1.014139 |
key = args['--key']
if key:
return [key]
keyfile = args['--apikeys']
if keyfile:
return read_keyfile(keyfile)
envkey = os.environ.get('TINYPNG_API_KEY', None)
if envkey:
return [envkey]
local_keys = join(abspath("."), "tinypng.keys")
if isfile(local_keys)... | def find_keys(args) | Get keys specified in arguments
returns list of keys or None | 2.844279 | 2.955064 | 0.96251 |
if api_key:
return _shrink_info(in_data, api_key)
api_keys = find_keys()
for key in api_keys:
try:
return _shrink_info(in_data, key)
except ValueError:
pass
raise ValueError('No valid api key found') | def get_shrink_data_info(in_data, api_key=None) | Shrink binary data of a png
returns api_info | 3.009577 | 3.060522 | 0.983354 |
out_url = shrink_info['output']['url']
try:
return requests.get(out_url).content
except HTTPError as err:
if err.code != 404:
raise
exc = ValueError("Unable to read png file \"{0}\"".format(out_url))
exc.__cause__ = err
raise exc | def get_shrunk_data(shrink_info) | Read shrunk file from tinypng.org api. | 4.276102 | 3.960966 | 1.079561 |
info = get_shrink_data_info(in_data, api_key)
return info, get_shrunk_data(info) | def shrink_data(in_data, api_key=None) | Shrink binary data of a png
returns (api_info, shrunk_data) | 5.498662 | 4.540994 | 1.210894 |
info = get_shrink_file_info(in_filepath, api_key, out_filepath)
write_shrunk_file(info)
return info | def shrink_file(in_filepath, api_key=None, out_filepath=None) | Shrink png file and write it back to a new file
The default file path replaces ".png" with ".tiny.png".
returns api_info (including info['ouput']['filepath']) | 4.482489 | 3.916541 | 1.144502 |
your_signature = b64encode(HMAC(b64decode(api_key), json_str.encode("utf-8"), sha256).digest()).decode("utf-8")
if len(signature) != len(your_signature):
return False
# avoid timing attack with constant time equality check
signatures_equal = True
for x, y in zip(signature, your_signat... | def verify_telesign_callback_signature(api_key, signature, json_str) | Verify that a callback was made by TeleSign and was not sent by a malicious client by verifying the signature.
:param api_key: the TeleSign API api_key associated with your account.
:param signature: the TeleSign Authorization header value supplied in the callback, as a string.
:param json_str: the POST bo... | 3.182842 | 3.716149 | 0.856489 |
try:
if isinstance(position, list):
self.send('position startpos moves {}'.format(
self.__listtostring(position)))
self.isready()
elif re.match('\s*^(((?:[rnbqkpRNBQKP1-8]+\/){7})[rnbqkpRNBQKP1-8]+)\s([b|w])\s([K|Q|k|q|-]{1,4})... | def setposition(self, position) | The move format is in long algebraic notation.
Takes list of stirngs = ['e2e4', 'd7d5']
OR
FEN = 'rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3 0 1' | 2.710451 | 2.509965 | 1.079876 |
if clock is None:
clock = self.clock
if self._config.data_type == "items":
item = {"host": host, "key": key,
"value": value, "clock": clock, "state": state}
elif self._config.data_type == "lld":
item = {"host": host, "key": key, "c... | def add_item(self, host, key, value, clock=None, state=0) | Add a single item into DataContainer
:host: hostname to which item will be linked to
:key: item key as defined in Zabbix
:value: item value
:clock: timestemp as integer. If not provided self.clock()) will be used | 2.96477 | 3.176808 | 0.933254 |
for host in data:
for key in data[host]:
if not data[host][key] == []:
self.add_item(host, key, data[host][key]) | def add(self, data) | Add a list of item into the container
:data: dict of items & value per hostname | 3.597444 | 3.146434 | 1.14334 |
if self.logger: # pragma: no cover
self.logger.info("Starting to send %d items" % len(self._items_list))
try:
# Zabbix trapper send a maximum of 250 items in bulk
# We have to respect that, in case of enforcement on zabbix server side
# Special ca... | def send(self) | Entrypoint to send data to Zabbix
If debug is enabled, items are sent one by one
If debug isn't enable, we send items in bulk
Returns a list of results (1 if no debug, as many as items in other case) | 3.206055 | 3.064106 | 1.046326 |
total = len(item)
processed = failed = time = 0
if self._config.dryrun is True:
total = len(item)
processed = failed = time = 0
response = 'dryrun'
else:
self._send_to_zabbix(item)
response, processed, failed, total, ti... | def _send_common(self, item) | Common part of sending operations
Calls SenderProtocol._send_to_zabbix
Returns result as provided by _handle_response
:item: either a list or a single item depending on debug_level | 4.462229 | 3.989784 | 1.118414 |
# Reset DataContainer to default values
# So that it can be reused
if self.logger: # pragma: no cover
self.logger.info("Reset DataContainer")
self._items_list = []
self._config.data_type = None | def _reset(self) | Reset main DataContainer properties | 8.925764 | 6.809597 | 1.310762 |
if isinstance(value, logging.Logger):
self._logger = value
else:
if self._logger: # pragma: no cover
self._logger.error("logger requires a logging instance")
raise ValueError('logger requires a logging instance') | def logger(self, value) | Set logger instance for the class | 3.699106 | 3.668442 | 1.008359 |
if event_name not in self.event_callbacks.keys():
self.event_callbacks[event_name] = []
self.event_callbacks[event_name].append(callback) | def bind(self, event_name, callback) | Bind an event to a callback
:param event_name: The name of the event to bind to.
:type event_name: str
:param callback: The callback to notify of this event. | 2.136 | 2.387352 | 0.894715 |
return self._get(self.API_URL + 'issue/{}'.format(issue_id), params=params) | def get_issue(self, issue_id, params=None) | Returns a full representation of the issue for the given issue key.
The issue JSON consists of the issue key and a collection of fields. Additional information like links to
workflow transition sub-resources, or HTML rendered values of the fields supporting HTML rendering can be
retrieved with ... | 4.071681 | 7.118569 | 0.57198 |
return self._post(self.API_URL + 'issue', data=data, params=params) | def create_issue(self, data, params=None) | Creates an issue or a sub-task from a JSON representation.
You can provide two parameters in request's body: update or fields. The fields, that can be set on an issue
create operation, can be determined using the /rest/api/2/issue/createmeta resource. If a particular field is
not configured to ... | 4.524272 | 7.504494 | 0.602875 |
return self._delete(self.API_URL + 'issue/{}'.format(issue_id), params=params) | def delete_issue(self, issue_id, params=None) | Deletes an individual issue.
If the issue has sub-tasks you must set the deleteSubtasks=true parameter to delete the issue. You cannot delete
an issue without deleting its sub-tasks.
Args:
issue_id:
params:
Returns: | 4.273329 | 7.599045 | 0.562351 |
data = {'channel': channel_name}
if channel_name.startswith('presence-'):
data['auth'] = self._generate_presence_key(
self.connection.socket_id,
self.key,
channel_name,
self.secret,
self.user_data
... | def subscribe(self, channel_name) | Subscribe to a channel
:param channel_name: The name of the channel to subscribe to.
:type channel_name: str
:rtype : Channel | 2.497946 | 2.61956 | 0.953575 |
zbx_answer = json.loads(zbx_answer)
if self._logger: # pragma: no cover
self._logger.info(
"Anaylizing Zabbix Server's answer"
)
if zbx_answer:
self._logger.debug("Zabbix Server response is: [%s]" % zbx_answer)
# Defau... | def _handle_response(self, zbx_answer) | Analyze Zabbix Server response
Returns a list with number of:
* processed items
* failed items
* total items
* time spent
:zbx_answer: Zabbix server response as string | 6.49634 | 5.586617 | 1.16284 |
if page_size and pagination:
try:
page_size = int(page_size)
except (ValueError, TypeError):
page_size = 100
queryparams['page_size'] = page_size
result = self.requester.get(
self.instance.endpoint, query=queryparam... | def list(self, pagination=True, page_size=None, page=None, **queryparams) | Retrieves a list of objects.
By default uses local cache and remote pagination
If pagination is used and no page is requested (the default), all the
remote objects are retrieved and appended in a single list.
If pagination is disabled, all the objects are fetched from the
endp... | 2.309012 | 2.299076 | 1.004322 |
result_entries = SearchableList()
for entry in entries:
result_entries.append(cls.instance.parse(requester, entry))
return result_entries | def parse(cls, requester, entries) | Parse a JSON array into a list of model instances. | 4.371881 | 4.129936 | 1.058583 |
result_entries = SearchableList()
for entry in entries:
result_entries.append(self.instance.parse(self.requester, entry))
return result_entries | def parse_list(self, entries) | Parse a JSON array into a list of model instances. | 6.248505 | 5.537315 | 1.128436 |
self_dict = self.to_dict()
if args:
self_dict = dict(list(self_dict.items()) + list(args.items()))
response = self.requester.put(
'/{endpoint}/{id}', endpoint=self.endpoint,
id=self.id, payload=self_dict
)
obj_json = response.json()
... | def update(self, **args) | Update the current :class:`InstanceResource` | 3.087749 | 2.992883 | 1.031697 |
self_dict = dict([(key, value) for (key, value) in
self.to_dict().items()
if key in fields])
if args:
self_dict = dict(list(self_dict.items()) + list(args.items()))
response = self.requester.patch(
'/{endpoint}/... | def patch(self, fields, **args) | Patch the current :class:`InstanceResource` | 2.964334 | 2.960832 | 1.001183 |
self.requester.delete(
'/{endpoint}/{id}', endpoint=self.endpoint,
id=self.id
)
return self | def delete(self) | Delete the current :class:`InstanceResource` | 6.730297 | 6.132173 | 1.097539 |
self_dict = {}
for key, value in six.iteritems(self.__dict__):
if self.allowed_params and key in self.allowed_params:
self_dict[key] = value
return self_dict | def to_dict(self) | Get a dictionary representation of :class:`InstanceResource` | 3.274606 | 3.214596 | 1.018668 |
if not type(entry) is dict:
return entry
for key_to_parse, cls_to_parse in six.iteritems(cls.parser):
if key_to_parse in entry:
entry[key_to_parse] = cls_to_parse.parse(
requester, entry[key_to_parse]
)
return c... | def parse(cls, requester, entry) | Turns a JSON object into a model instance. | 2.753004 | 2.531267 | 1.087599 |
attributes = self._get_attributes(cache=True)
formatted_id = '{0}'.format(id)
attributes['attributes_values'][formatted_id] = value
response = self.requester.patch(
'/{endpoint}/custom-attributes-values/{id}',
endpoint=self.endpoint, id=self.id,
... | def set_attribute(self, id, value, version=1) | Set attribute to a specific value
:param id: id of the attribute
:param value: value of the attribute
:param version: version of the attribute (default = 1) | 3.520607 | 3.549789 | 0.991779 |
attrs.update(
{
'project': project, 'name': name
}
)
return self._new_resource(payload=attrs) | def create(self, project, name, **attrs) | Create a new :class:`CustomAttribute`.
:param project: :class:`Project` id
:param name: name of the custom attribute
:param attrs: optional attributes of the custom attributes | 5.578958 | 8.958556 | 0.622752 |
response = self.requester.get(
'/{endpoint}/{id}/starred', endpoint=self.endpoint,
id=self.id
)
return Projects.parse(self.requester, response.json()) | def starred_projects(self) | Get a list of starred :class:`Project`. | 4.649196 | 4.065416 | 1.143597 |
attrs.update({'project': project, 'email': email, 'role': role})
return self._new_resource(payload=attrs) | def create(self, project, email, role, **attrs) | Create a new :class:`Membership`.
:param project: :class:`Project` id
:param email: email of the :class:`Membership`
:param role: role of the :class:`Membership`
:param attrs: optional attributes of the :class:`Membership` | 4.197379 | 5.833217 | 0.719565 |
attrs.update({'project': project, 'object_id': object_id})
if isinstance(attached_file, file):
attachment = attached_file
elif isinstance(attached_file, six.string_types):
try:
attachment = open(attached_file, 'rb')
except IOError:
... | def create(self, project, object_id, attached_file, **attrs) | Create a new :class:`Attachment`.
:param project: :class:`Project` id
:param object_id: id of the current object
:param ref: :class:`Task` reference
:param attached_file: file path that you want to upload
:param attrs: optional attributes for the :class:`Attachment` | 2.822417 | 2.889447 | 0.976802 |
return Tasks(self.requester).create(
self.project, subject, status,
user_story=self.id, **attrs
) | def add_task(self, subject, status, **attrs) | Add a :class:`Task` to the current :class:`UserStory` and return it.
:param subject: subject of the :class:`Task`
:param status: status of the :class:`Task`
:param attrs: optional attributes for :class:`Task` | 9.451017 | 9.751181 | 0.969218 |
attrs.update({'project': project, 'subject': subject})
return self._new_resource(payload=attrs) | def create(self, project, subject, **attrs) | Create a new :class:`UserStory`.
:param project: :class:`Project` id
:param subject: subject of the :class:`UserStory`
:param attrs: optional attributes of the :class:`UserStory` | 5.546158 | 7.712212 | 0.71914 |
response = self.requester.get(
'/{endpoint}/{id}/stats',
endpoint=self.endpoint, id=self.id
)
return response.json() | def stats(self) | Get the stats for the current :class:`Milestone` | 5.246786 | 4.261161 | 1.231304 |
if isinstance(estimated_start, datetime.datetime):
estimated_start = estimated_start.strftime('%Y-%m-%d')
if isinstance(estimated_finish, datetime.datetime):
estimated_finish = estimated_finish.strftime('%Y-%m-%d')
attrs.update({
'project': project,
... | def create(self, project, name, estimated_start,
estimated_finish, **attrs) | Create a new :class:`Milestone`.
:param project: :class:`Project` id
:param name: name of the :class:`Milestone`
:param estimated_start: est. start time of the :class:`Milestone`
:param estimated_finish: est. finish time of the :class:`Milestone`
:param attrs: optional attribute... | 1.722262 | 1.94536 | 0.885318 |
return TaskAttachments(self.requester).create(
self.project, self.id,
attached_file, **attrs
) | def attach(self, attached_file, **attrs) | Attach a file to the :class:`Task`
:param attached_file: file path to attach
:param attrs: optional attributes for the attached file | 7.793087 | 10.060413 | 0.774629 |
self.requester.post(
'/{endpoint}/{id}/upvote',
endpoint=self.endpoint, id=self.id
)
return self | def upvote(self) | Upvote :class:`Issue`. | 6.244735 | 5.077234 | 1.229948 |
self.requester.post(
'/{endpoint}/{id}/downvote',
endpoint=self.endpoint, id=self.id
)
return self | def downvote(self) | Downvote :class:`Issue`. | 6.319149 | 5.397732 | 1.170705 |
attrs.update(
{
'project': project, 'subject': subject,
'priority': priority, 'status': status,
'type': issue_type, 'severity': severity
}
)
return self._new_resource(payload=attrs) | def create(self, project, subject, priority, status,
issue_type, severity, **attrs) | Create a new :class:`Task`.
:param project: :class:`Project` id
:param subject: subject of the :class:`Issue`
:param priority: priority of the :class:`Issue`
:param status: status of the :class:`Issue`
:param issue_type: Issue type of the :class:`Issue`
:param severity: ... | 2.752292 | 3.113488 | 0.88399 |
response = self.requester.get(
'/{endpoint}/by_ref?ref={task_ref}&project={project_id}',
endpoint=Task.endpoint,
task_ref=ref,
project_id=self.id
)
return Task.parse(self.requester, response.json()) | def get_task_by_ref(self, ref) | Get a :class:`Task` by ref.
:param ref: :class:`Task` reference | 4.477292 | 4.639143 | 0.965112 |
response = self.requester.get(
'/{endpoint}/by_ref?ref={us_ref}&project={project_id}',
endpoint=UserStory.endpoint,
us_ref=ref,
project_id=self.id
)
return UserStory.parse(self.requester, response.json()) | def get_userstory_by_ref(self, ref) | Get a :class:`UserStory` by ref.
:param ref: :class:`UserStory` reference | 4.662138 | 4.819485 | 0.967352 |
response = self.requester.get(
'/{endpoint}/by_ref?ref={us_ref}&project={project_id}',
endpoint=Issue.endpoint,
us_ref=ref,
project_id=self.id
)
return Issue.parse(self.requester, response.json()) | def get_issue_by_ref(self, ref) | Get a :class:`Issue` by ref.
:param ref: :class:`Issue` reference | 5.061597 | 5.189171 | 0.975415 |
response = self.requester.get(
'/{endpoint}/{id}/issues_stats',
endpoint=self.endpoint, id=self.id
)
return response.json() | def issues_stats(self) | Get stats for issues of the project | 5.039063 | 4.481844 | 1.124328 |
self.requester.post(
'/{endpoint}/{id}/like',
endpoint=self.endpoint, id=self.id
)
return self | def like(self) | Like the project | 7.054003 | 6.097103 | 1.156943 |
self.requester.post(
'/{endpoint}/{id}/unlike',
endpoint=self.endpoint, id=self.id
)
return self | def unlike(self) | Unlike the project | 5.676923 | 5.790205 | 0.980436 |
warnings.warn(
"Deprecated! Update Taiga and use .like() instead",
DeprecationWarning
)
self.requester.post(
'/{endpoint}/{id}/star',
endpoint=self.endpoint, id=self.id
)
return self | def star(self) | Stars the project
.. deprecated:: 0.8.5
Update Taiga and use like instead | 10.115465 | 5.767373 | 1.753912 |
return Memberships(self.requester).create(
self.id, email, role, **attrs
) | def add_membership(self, email, role, **attrs) | Add a Membership to the project and returns a
:class:`Membership` resource.
:param email: email for :class:`Membership`
:param role: role for :class:`Membership`
:param attrs: role for :class:`Membership`
:param attrs: optional :class:`Membership` attributes | 6.331998 | 9.505736 | 0.666124 |
return UserStories(self.requester).create(
self.id, subject, **attrs
) | def add_user_story(self, subject, **attrs) | Adds a :class:`UserStory` and returns a :class:`UserStory` resource.
:param subject: subject of the :class:`UserStory`
:param attrs: other :class:`UserStory` attributes | 7.924753 | 12.065829 | 0.656793 |
return UserStories(self.requester).import_(
self.id, subject, status, **attrs
) | def import_user_story(self, subject, status, **attrs) | Import an user story and returns a :class:`UserStory` resource.
:param subject: subject of the :class:`UserStory`
:param status: status of the :class:`UserStory`
:param attrs: optional :class:`UserStory` attributes | 7.638451 | 10.962865 | 0.696757 |
return Issues(self.requester).create(
self.id, subject, priority, status,
issue_type, severity, **attrs
) | def add_issue(self, subject, priority, status,
issue_type, severity, **attrs) | Adds a Issue and returns a :class:`Issue` resource.
:param subject: subject of the :class:`Issue`
:param priority: priority of the :class:`Issue`
:param priority: status of the :class:`Issue`
:param issue_type: type of the :class:`Issue`
:param severity: severity of the :class:`... | 4.124382 | 5.615512 | 0.734462 |
return Issues(self.requester).import_(
self.id, subject, priority, status,
issue_type, severity, **attrs
) | def import_issue(self, subject, priority, status,
issue_type, severity, **attrs) | Import and issue and returns a :class:`Issue` resource.
:param subject: subject of :class:`Issue`
:param priority: priority of :class:`Issue`
:param status: status of :class:`Issue`
:param issue_type: issue type of :class:`Issue`
:param severity: severity of :class:`Issue`
... | 4.62919 | 6.920537 | 0.668906 |
return Milestones(self.requester).create(
self.id, name, estimated_start,
estimated_finish, **attrs
) | def add_milestone(self, name, estimated_start, estimated_finish, **attrs) | Add a Milestone to the project and returns a :class:`Milestone` object.
:param name: name of the :class:`Milestone`
:param estimated_start: estimated start time of the
:class:`Milestone`
:param estimated_finish: estimated finish time of the
... | 4.646888 | 6.956872 | 0.667956 |
return Milestones(self.requester).import_(
self.id, name, estimated_start,
estimated_finish, **attrs
) | def import_milestone(self, name, estimated_start, estimated_finish,
**attrs) | Import a Milestone and returns a :class:`Milestone` object.
:param name: name of the :class:`Milestone`
:param estimated_start: estimated start time of the
:class:`Milestone`
:param estimated_finish: estimated finish time of the
:... | 5.341069 | 8.437447 | 0.63302 |
return Milestones(self.requester).list(project=self.id, **queryparams) | def list_milestones(self, **queryparams) | Get the list of :class:`Milestone` resources for the project. | 6.638453 | 5.94508 | 1.11663 |
return Points(self.requester).create(self.id, name, value, **attrs) | def add_point(self, name, value, **attrs) | Add a Point to the project and returns a :class:`Point` object.
:param name: name of the :class:`Point`
:param value: value of the :class:`Point`
:param attrs: optional attributes for :class:`Point` | 8.131336 | 11.791322 | 0.689603 |
return TaskStatuses(self.requester).create(self.id, name, **attrs) | def add_task_status(self, name, **attrs) | Add a Task status to the project and returns a
:class:`TaskStatus` object.
:param name: name of the :class:`TaskStatus`
:param attrs: optional attributes for :class:`TaskStatus` | 7.97073 | 13.632492 | 0.584686 |
return Tasks(self.requester).import_(
self.id, subject, status, **attrs
) | def import_task(self, subject, status, **attrs) | Import a Task and return a :class:`Task` object.
:param subject: subject of the :class:`Task`
:param status: status of the :class:`Task`
:param attrs: optional attributes for :class:`Task` | 8.521777 | 14.37106 | 0.592982 |
return UserStoryStatuses(self.requester).create(self.id, name, **attrs) | def add_user_story_status(self, name, **attrs) | Add a UserStory status to the project and returns a
:class:`UserStoryStatus` object.
:param name: name of the :class:`UserStoryStatus`
:param attrs: optional attributes for :class:`UserStoryStatus` | 6.575365 | 10.703981 | 0.614291 |
return IssueTypes(self.requester).create(self.id, name, **attrs) | def add_issue_type(self, name, **attrs) | Add a Issue type to the project and returns a
:class:`IssueType` object.
:param name: name of the :class:`IssueType`
:param attrs: optional attributes for :class:`IssueType` | 7.587869 | 10.727738 | 0.707313 |
return Severities(self.requester).create(self.id, name, **attrs) | def add_severity(self, name, **attrs) | Add a Severity to the project and returns a :class:`Severity` object.
:param name: name of the :class:`Severity`
:param attrs: optional attributes for :class:`Severity` | 7.748647 | 10.62501 | 0.729284 |
return Roles(self.requester).create(self.id, name, **attrs) | def add_role(self, name, **attrs) | Add a Role to the project and returns a :class:`Role` object.
:param name: name of the :class:`Role`
:param attrs: optional attributes for :class:`Role` | 8.533946 | 14.253139 | 0.598741 |
return Priorities(self.requester).create(self.id, name, **attrs) | def add_priority(self, name, **attrs) | Add a Priority to the project and returns a :class:`Priority` object.
:param name: name of the :class:`Priority`
:param attrs: optional attributes for :class:`Priority` | 8.539104 | 10.926492 | 0.781505 |
return IssueStatuses(self.requester).create(self.id, name, **attrs) | def add_issue_status(self, name, **attrs) | Add a Issue status to the project and returns a
:class:`IssueStatus` object.
:param name: name of the :class:`IssueStatus`
:param attrs: optional attributes for :class:`IssueStatus` | 7.012169 | 10.607965 | 0.661029 |
return WikiPages(self.requester).create(
self.id, slug, content, **attrs
) | def add_wikipage(self, slug, content, **attrs) | Add a Wiki page to the project and returns a :class:`WikiPage` object.
:param name: name of the :class:`WikiPage`
:param attrs: optional attributes for :class:`WikiPage` | 7.828063 | 12.106231 | 0.646614 |
return WikiPages(self.requester).import_(
self.id, slug, content, **attrs
) | def import_wikipage(self, slug, content, **attrs) | Import a Wiki page and return a :class:`WikiPage` object.
:param slug: slug of the :class:`WikiPage`
:param content: content of the :class:`WikiPage`
:param attrs: optional attributes for :class:`Task` | 8.127959 | 12.57866 | 0.646171 |
return WikiLinks(self.requester).create(self.id, title, href, **attrs) | def add_wikilink(self, title, href, **attrs) | Add a Wiki link to the project and returns a :class:`WikiLink` object.
:param title: title of the :class:`WikiLink`
:param href: href of the :class:`WikiLink`
:param attrs: optional attributes for :class:`WikiLink` | 9.311808 | 9.700204 | 0.95996 |
return WikiLinks(self.requester).import_(self.id, title, href, **attrs) | def import_wikilink(self, title, href, **attrs) | Import a Wiki link and return a :class:`WikiLink` object.
:param title: title of the :class:`WikiLink`
:param href: href of the :class:`WikiLink`
:param attrs: optional attributes for :class:`WikiLink` | 9.958014 | 13.80264 | 0.721457 |
return IssueAttributes(self.requester).create(
self.id, name, **attrs
) | def add_issue_attribute(self, name, **attrs) | Add a new Issue attribute and return a :class:`IssueAttribute` object.
:param name: name of the :class:`IssueAttribute`
:param attrs: optional attributes for :class:`IssueAttribute` | 8.427223 | 11.601445 | 0.726394 |
return TaskAttributes(self.requester).create(
self.id, name, **attrs
) | def add_task_attribute(self, name, **attrs) | Add a new Task attribute and return a :class:`TaskAttribute` object.
:param name: name of the :class:`TaskAttribute`
:param attrs: optional attributes for :class:`TaskAttribute` | 9.880844 | 14.273795 | 0.692237 |
return UserStoryAttributes(self.requester).create(
self.id, name, **attrs
) | def add_user_story_attribute(self, name, **attrs) | Add a new User Story attribute and return a
:class:`UserStoryAttribute` object.
:param name: name of the :class:`UserStoryAttribute`
:param attrs: optional attributes for :class:`UserStoryAttribute` | 7.511163 | 10.975125 | 0.684381 |
return Webhooks(self.requester).create(
self.id, name, url, key, **attrs
) | def add_webhook(self, name, url, key, **attrs) | Add a new Webhook and return a :class:`Webhook` object.
:param name: name of the :class:`Webhook`
:param url: payload url of the :class:`Webhook`
:param key: secret key of the :class:`Webhook`
:param attrs: optional attributes for :class:`Webhook` | 5.30916 | 9.250486 | 0.573933 |
attrs.update({'name': name, 'description': description})
return self._new_resource(payload=attrs) | def create(self, name, description, **attrs) | Create a new :class:`Project`
:param name: name of the :class:`Project`
:param description: description of the :class:`Project`
:param attrs: optional attributes for :class:`Project` | 4.797126 | 6.677552 | 0.718396 |
response = self.requester.get(
'/{endpoint}/by_slug?slug={slug}',
endpoint=self.instance.endpoint,
slug=slug
)
return self.instance.parse(self.requester, response.json()) | def get_by_slug(self, slug) | Get a :class:`Project` by slug
:param slug: the slug of the :class:`Project` | 4.626163 | 4.822854 | 0.959217 |
attrs.update({'project': project, 'slug': slug, 'content': content})
return self._new_resource(payload=attrs) | def create(self, project, slug, content, **attrs) | create a new :class:`WikiPage`
:param project: :class:`Project` id
:param slug: slug of the wiki page
:param content: content of the wiki page
:param attrs: optional attributes for the :class:`WikiPage` | 4.222971 | 5.701791 | 0.740639 |
attrs.update({'project': project, 'title': title, 'href': href})
return self._new_resource(payload=attrs) | def create(self, project, title, href, **attrs) | Create a new :class:`WikiLink`
:param project: :class:`Project` id
:param title: title of the wiki link
:param href: href for the wiki link
:param attrs: optional attributes for the :class:`WikiLink` | 4.873233 | 5.657485 | 0.861378 |
response = self.requester.get(
'/{endpoint}/{entity}/{id}',
endpoint=self.endpoint, entity=self.entity, id=resource_id,
paginate=False
)
return response.json() | def get(self, resource_id) | Get a history element
:param resource_id: ... | 4.71472 | 4.680089 | 1.0074 |
self.requester.post(
'/{endpoint}/{entity}/{id}/delete_comment?id={ent_id}',
endpoint=self.endpoint, entity=self.entity,
id=resource_id, ent_id=ent_id
) | def delete_comment(self, resource_id, ent_id) | Delete a comment
:param resource_id: ...
:param ent_id: ... | 3.832971 | 4.001 | 0.958003 |
if is_list_annotation(cls):
if not isinstance(value, list):
raise TypeError('Could not parse {} because value is not a list'.format(cls))
return [parse(cls.__args__[0], o) for o in value]
else:
return GenericParser(cls, ModelProviderImpl()).parse(value) | def parse(cls, value) | Takes a class and a dict and try to build an instance of the class
:param cls: The class to parse
:param value: either a dict, a list or a scalar value | 5.177944 | 5.460711 | 0.948218 |
kwargs['default'] = serialize
return json.dump(obj, fp, **kwargs) | def dump(obj, fp, **kwargs) | wrapper for :py:func:`json.dump` | 4.707854 | 4.22333 | 1.114726 |
json_obj = json.load(fp, **kwargs)
return parse(cls, json_obj) | def load(cls, fp, **kwargs) | wrapper for :py:func:`json.load` | 4.746511 | 4.086876 | 1.161403 |
json_obj = json.loads(s, **kwargs)
return parse(cls, json_obj) | def loads(cls, s, **kwargs) | wrapper for :py:func:`json.loads` | 4.461234 | 4.243892 | 1.051213 |
if 'ENST' in ensembl:
pass
else:
raise (IndexError)
# Submit resquest to NCBI eutils/Gene database
server = "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?" + self.options + "&db=gene&term={0}".format(
ensembl)
r = requests... | def convert_ensembl_to_entrez(self, ensembl) | Convert Ensembl Id to Entrez Gene Id | 3.665829 | 3.472533 | 1.055664 |
server = "http://www.uniprot.org/uniprot/?query=%22GENEID+{0}%22&format=xml".format(entrez)
r = requests.get(server, headers={"Content-Type": "text/xml"})
if not r.ok:
r.raise_for_status()
sys.exit()
response = r.text
info = xmltodict.parse(respon... | def convert_entrez_to_uniprot(self, entrez) | Convert Entrez Id to Uniprot Id | 2.767614 | 2.658272 | 1.041133 |
# Submit request to NCBI eutils/Gene Database
server = "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?" + self.options + "&db=gene&term={0}".format(
uniprot)
r = requests.get(server, headers={"Content-Type": "text/xml"})
if not r.ok:
r.raise_f... | def convert_uniprot_to_entrez(self, uniprot) | Convert Uniprot Id to Entrez Id | 3.966643 | 3.769288 | 1.052359 |
# Submit request to NCBI eutils/Taxonomy Database
server = "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?" + self.options + "&db=nuccore&id={0}&retmode=xml".format(
accessionid)
r = requests.get(server, headers={"Content-Type": "text/xml"})
if not r.ok:
... | def convert_accession_to_taxid(self, accessionid) | Convert Accession Id to Tax Id | 2.406546 | 2.346551 | 1.025567 |
entrezdict = {}
server = "http://rest.genenames.org/fetch/symbol/{0}".format(symbol)
r = requests.get(server, headers={"Content-Type": "application/json"})
if not r.ok:
r.raise_for_status()
sys.exit()
response = r.text
info = xmltodict.par... | def convert_symbol_to_entrezid(self, symbol) | Convert Symbol to Entrez Gene Id | 2.70159 | 2.70373 | 0.999208 |
prefix = '{} {}'.format(color('INFO', fg=248), color('request', fg=5))
message = message_format % args
sys.stderr.write('{} {}\n'.format(prefix, message)) | def log_local_message(message_format, *args) | Log a request so that it matches our local log format. | 6.950015 | 6.149471 | 1.130181 |
if isinstance(obj, list):
return [serialize(o) for o in obj]
return GenericSerializer(ModelProviderImpl()).serialize(obj) | def serialize(obj) | Takes a object and produces a dict-like representation
:param obj: the object to serialize | 7.961855 | 10.585248 | 0.752165 |
if self.closed_by is None:
self.expects_body_or_pass = True
for block in indented_blocks:
if block is not None:
self._blocks.append((1, block))
# Finalise it so that we cannot add more sub-blocks to this block.
self.finalise()
... | def of(self, *indented_blocks) -> "CodeBlock" | By default, marks the block as expecting an indented "body" blocks of which are then supplied
as arguments to this method.
Unless the block specifies a "closed_by", if no body blocks are supplied or they are all Nones,
this will generate a "pass" statement as the body. If there is a "closed_by"... | 8.141226 | 5.657016 | 1.439138 |
for block in blocks:
if block is not None:
self._blocks.append((indentation, block))
return self | def add(self, *blocks, indentation=0) -> "CodeBlock" | Adds sub-blocks at the specified indentation level, which defaults to 0.
Nones are skipped.
Returns the parent block itself, useful for chaining. | 3.852764 | 4.461565 | 0.863545 |
self.process_triple_quoted_doc_string()
num_indented_blocks = 0
for indentation, block in self._blocks:
if indentation > 0:
num_indented_blocks += 1
yield indentation, block
if self.expects_body_or_pass and num_indented_blocks == 0:
... | def get_blocks(self) | Override this method for custom content, but then you are responsible for:
- generating doc string (you can call self.process_triple_quoted_doc_string())
- generating "pass" on empty body | 5.421792 | 3.105218 | 1.746026 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.