code string | signature string | docstring string | loss_without_docstring float64 | loss_with_docstring float64 | factor float64 |
|---|---|---|---|---|---|
run('tox -e py27 -- --cassette-mode all --record --credentials {0} -s'
.format(rest), pty=True)
run('tox -e py27 -- --resave --scrub --credentials test_credentials {0} -s'
.format(rest), pty=True) | def rerecord(ctx, rest) | Rerecord tests. | 9.402845 | 9.298607 | 1.01121 |
requests_session = requests_session or requests.Session()
session = cls(requests_session, rate_limit)
# settings.USERNAME and settings.PASSWORD should not be made
# the defaults to their respective arguments because doing so
# would prevent this function from picking up ... | def login(
cls, username=None, password=None, requests_session=None,
rate_limit=None
) | Get a session that has authenticated with okcupid.com.
If no username and password is supplied, the ones stored in
:class:`okcupyd.settings` will be used.
:param username: The username to log in with.
:type username: str
:param password: The password to log in with.
:typ... | 5.618243 | 6.047665 | 0.928994 |
# no need to retrieve all the entries from _get_paged_resources
# role raw data is very simple that contains no other links
self.log.info("Get all the roles in <ProjectArea %s>",
self)
roles_url = "/".join([self.rtc_obj.url,
... | def getRoles(self) | Get all :class:`rtcclient.models.Role` objects in this project
area
If no :class:`Roles` are retrieved, `None` is returned.
:return: a :class:`list` that contains all
:class:`rtcclient.models.Role` objects
:rtype: list | 4.684582 | 4.290269 | 1.091909 |
if not isinstance(label, six.string_types) or not label:
excp_msg = "Please specify a valid role label"
self.log.error(excp_msg)
raise exception.BadValue(excp_msg)
roles = self.getRoles()
if roles is not None:
for role in roles:
... | def getRole(self, label) | Get the :class:`rtcclient.models.Role` object by the label name
:param label: the label name of the role
:return: the :class:`rtcclient.models.Role` object
:rtype: :class:`rtcclient.models.Role` | 3.258779 | 3.182111 | 1.024094 |
if not isinstance(email, six.string_types) or "@" not in email:
excp_msg = "Please specify a valid email address name"
self.log.error(excp_msg)
raise exception.BadValue(excp_msg)
self.log.debug("Try to get Member whose email is %s>", email)
members ... | def getMember(self, email, returned_properties=None) | Get the :class:`rtcclient.models.Member` object by the
email address
:param email: the email address (e.g. somebody@gmail.com)
:param returned_properties: the returned properties that you want.
Refer to :class:`rtcclient.client.RTCClient` for more explanations
:return: the :... | 3.375256 | 3.471037 | 0.972406 |
if not isinstance(title, six.string_types) or not title:
excp_msg = "Please specify a valid email address name"
self.log.error(excp_msg)
raise exception.BadValue(excp_msg)
self.log.debug("Try to get <ItemType %s>", title)
itemtypes = self._getItemTy... | def getItemType(self, title, returned_properties=None) | Get the :class:`rtcclient.models.ItemType` object by the title
:param title: the title (e.g. Story/Epic/..)
:param returned_properties: the returned properties that you want.
Refer to :class:`rtcclient.client.RTCClient` for more explanations
:return: the :class:`rtcclient.models.Ite... | 3.51927 | 3.649962 | 0.964194 |
if not isinstance(email, six.string_types) or "@" not in email:
excp_msg = "Please specify a valid email address name"
self.log.error(excp_msg)
raise exception.BadValue(excp_msg)
self.log.debug("Try to get Administrator whose email is %s",
... | def getAdministrator(self, email, returned_properties=None) | Get the :class:`rtcclient.models.Administrator` object
by the email address
:param email: the email address (e.g. somebody@gmail.com)
:param returned_properties: the returned properties that you want.
Refer to :class:`rtcclient.client.RTCClient` for more explanations
:return... | 3.645305 | 3.743615 | 0.973739 |
pa_id = (self.rtc_obj
._pre_get_resource(projectarea_id=projectarea_id,
projectarea_name=projectarea_name))
self.log.info("Start to query workitems with query string: %s",
query_str)
query_str = urlquot... | def queryWorkitems(self, query_str, projectarea_id=None,
projectarea_name=None, returned_properties=None,
archived=False) | Query workitems with the query string in a certain
:class:`rtcclient.project_area.ProjectArea`
At least either of `projectarea_id` and `projectarea_name` is given
:param query_str: a valid query string
:param projectarea_id: the :class:`rtcclient.project_area.ProjectArea`
i... | 4.929111 | 5.111958 | 0.964232 |
pa_id = (self.rtc_obj
._pre_get_resource(projectarea_id=projectarea_id,
projectarea_name=projectarea_name))
filter_rule = None
if creator is not None:
fcreator = self.rtc_obj.getOwnedBy(creator).url
f... | def getAllSavedQueries(self, projectarea_id=None, projectarea_name=None,
creator=None, saved_query_name=None) | Get all saved queries created by somebody (optional)
in a certain project area (optional, either `projectarea_id`
or `projectarea_name` is needed if specified)
If `saved_query_name` is specified, only the saved queries match the
name will be fetched.
Note: only if `creator` is ... | 3.485186 | 3.568767 | 0.97658 |
self.log.info("Start to fetch all saved queries with the name %s",
saved_query_name)
return self.getAllSavedQueries(projectarea_id=projectarea_id,
projectarea_name=projectarea_name,
creator=crea... | def getSavedQueriesByName(self, saved_query_name, projectarea_id=None,
projectarea_name=None, creator=None) | Get all saved queries match the name created by somebody (optional)
in a certain project area (optional, either `projectarea_id`
or `projectarea_name` is needed if specified)
Note: only if `creator` is added as a member, the saved queries
can be found. Otherwise None will be returned.
... | 2.436312 | 2.616597 | 0.931099 |
self.log.info("Start to fetch my saved queries")
return self.getAllSavedQueries(projectarea_id=projectarea_id,
projectarea_name=projectarea_name,
creator=self.rtc_obj.username,
... | def getMySavedQueries(self, projectarea_id=None, projectarea_name=None,
saved_query_name=None) | Get all saved queries created by me in a certain project
area (optional, either `projectarea_id` or `projectarea_name` is
needed if specified)
Note: only if myself is added as a member, the saved queries
can be found. Otherwise None will be returned.
WARNING: now the RTC server... | 3.792059 | 3.760062 | 1.008509 |
try:
if "=" not in saved_query_url:
raise exception.BadValue()
saved_query_id = saved_query_url.split("=")[-1]
if not saved_query_id:
raise exception.BadValue()
except:
error_msg = "No saved query id is found in th... | def runSavedQueryByUrl(self, saved_query_url, returned_properties=None) | Query workitems using the saved query url
:param saved_query_url: the saved query url
:param returned_properties: the returned properties that you want.
Refer to :class:`rtcclient.client.RTCClient` for more explanations
:return: a :class:`list` that contains the queried
... | 2.63247 | 2.83794 | 0.927599 |
if not isinstance(saved_query_id,
six.string_types) or not saved_query_id:
excp_msg = "Please specify a valid saved query id"
self.log.error(excp_msg)
raise exception.BadValue(excp_msg)
return self._runSavedQuery(saved_query_id,
... | def runSavedQueryByID(self, saved_query_id, returned_properties=None) | Query workitems using the saved query id
This saved query id can be obtained by below two methods:
1. :class:`rtcclient.models.SavedQuery` object (e.g.
mysavedquery.id)
2. your saved query url (e.g.
https://myrtc:9443/jazz/web/xxx#action=xxxx%id=_mGYe0CWgEeGofp83pg),
w... | 3.145956 | 3.412312 | 0.921943 |
try:
saved_query_id = saved_query_obj.results.split("/")[-2]
except:
error_msg = "Cannot get the correct saved query id"
self.log.error(error_msg)
raise exception.RTCException(error_msg)
return self._runSavedQuery(saved_query_id,
... | def runSavedQuery(self, saved_query_obj, returned_properties=None) | Query workitems using the :class:`rtcclient.models.SavedQuery`
object
:param saved_query_obj: the :class:`rtcclient.models.SavedQuery`
object
:param returned_properties: the returned properties that you want.
Refer to :class:`rtcclient.client.RTCClient` for more explanat... | 3.787802 | 3.450634 | 1.097712 |
self.log.debug("Put a request to %s with data: %s",
url, data)
response = requests.put(url, data=data,
verify=verify, headers=headers,
proxies=proxies, timeout=timeout, **kwargs)
if response.status_c... | def put(self, url, data=None, verify=False,
headers=None, proxies=None, timeout=60, **kwargs) | Sends a PUT request. Refactor from requests module
:param url: URL for the new :class:`Request` object.
:param data: (optional) Dictionary, bytes, or file-like object to
send in the body of the :class:`Request`.
:param verify: (optional) if ``True``, the SSL cert will be verified.
... | 2.462094 | 2.683414 | 0.917523 |
if url is None:
return None
url = url.strip()
while url.endswith('/'):
url = url[:-1]
return url | def validate_url(cls, url) | Strip and trailing slash to validate a url
:param url: the url address
:return: the valid url address
:rtype: string | 3.971969 | 3.476654 | 1.142469 |
self.log.debug("Start initializing data from %s",
self.url)
resp = self.get(self.url,
verify=False,
proxies=self.rtc_obj.proxies,
headers=self.rtc_obj.headers)
self.__initialize(resp)
... | def _initialize(self) | Initialize the object from the request | 6.790614 | 6.010438 | 1.129803 |
raw_data = xmltodict.parse(resp.content)
root_key = list(raw_data.keys())[0]
self.raw_data = raw_data.get(root_key)
self.__initializeFromRaw() | def __initialize(self, resp) | Initialize from the response | 3.882817 | 3.817046 | 1.017231 |
for (key, value) in self.raw_data.items():
if key.startswith("@"):
# be compatible with IncludedInBuild
if "@oslc_cm:label" != key:
continue
attr = key.split(":")[-1].replace("-", "_")
attr_list = attr.split(".")
... | def __initializeFromRaw(self) | Initialze from raw data (OrderedDict) | 5.931214 | 5.555076 | 1.067711 |
self.log.info("Cookie expires. Relogin to get a new cookie.")
self.headers = None
self.headers = self._get_headers()
self.log.debug("Successfully relogin.") | def relogin(self) | Relogin the RTC Server/Jazz when the token expires | 7.539517 | 7.061126 | 1.06775 |
return self._getProjectAreas(archived=archived,
returned_properties=returned_properties) | def getProjectAreas(self, archived=False, returned_properties=None) | Get all :class:`rtcclient.project_area.ProjectArea` objects
If no :class:`rtcclient.project_area.ProjectArea` objects are
retrieved, `None` is returned.
:param archived: (default is False) whether the project area
is archived
:param returned_properties: the returned propert... | 3.664274 | 5.090088 | 0.719884 |
if not isinstance(projectarea_name,
six.string_types) or not projectarea_name:
excp_msg = "Please specify a valid ProjectArea name"
self.log.error(excp_msg)
raise exception.BadValue(excp_msg)
self.log.debug("Try to get <ProjectArea... | def getProjectArea(self, projectarea_name, archived=False,
returned_properties=None) | Get :class:`rtcclient.project_area.ProjectArea` object by its name
:param projectarea_name: the project area name
:param archived: (default is False) whether the project area
is archived
:param returned_properties: the returned properties that you want.
Refer to :class:`... | 2.623978 | 2.652827 | 0.989125 |
if not isinstance(projectarea_id,
six.string_types) or not projectarea_id:
excp_msg = "Please specify a valid ProjectArea ID"
self.log.error(excp_msg)
raise exception.BadValue(excp_msg)
self.log.debug("Try to get <ProjectArea> by i... | def getProjectAreaByID(self, projectarea_id, archived=False,
returned_properties=None) | Get :class:`rtcclient.project_area.ProjectArea` object by its id
:param projectarea_id: the :class:`rtcclient.project_area.ProjectArea`
id
:param archived: (default is False) whether the project area
is archived
:param returned_properties: the returned properties that yo... | 2.879285 | 2.829186 | 1.017708 |
self.log.debug("Get the ProjectArea id by its name: %s",
projectarea_name)
proj_area = self.getProjectArea(projectarea_name,
archived=archived)
if proj_area:
return proj_area.id
raise exception.NotFound(... | def getProjectAreaID(self, projectarea_name, archived=False) | Get :class:`rtcclient.project_area.ProjectArea` id by its name
:param projectarea_name: the project area name
:param archived: (default is False) whether the project area
is archived
:return: the :class:`string` object
:rtype: string | 3.277981 | 3.045979 | 1.076166 |
projectarea_ids = list()
if projectarea_name and isinstance(projectarea_name,
six.string_types):
projectarea_id = self.getProjectAreaID(projectarea_name,
archived=archived)
pro... | def getProjectAreaIDs(self, projectarea_name=None, archived=False) | Get all :class:`rtcclient.project_area.ProjectArea` id(s)
by project area name
If `projectarea_name` is `None`, all the
:class:`rtcclient.project_area.ProjectArea` id(s) will be returned.
:param projectarea_name: the project area name
:param archived: (default is False) whether... | 2.226498 | 2.309027 | 0.964258 |
self.log.debug("Check the validity of the ProjectArea id: %s",
projectarea_id)
proj_areas = self._getProjectAreas(archived=archived,
projectarea_id=projectarea_id)
if proj_areas is not None:
proj_area = proj... | def checkProjectAreaID(self, projectarea_id, archived=False) | Check the validity of :class:`rtcclient.project_area.ProjectArea` id
:param projectarea_id: the :class:`rtcclient.project_area.ProjectArea`
id
:param archived: (default is False) whether the project area is
archived
:return: `True` or `False`
:rtype: bool | 3.041326 | 2.778465 | 1.094607 |
if not isinstance(teamarea_name,
six.string_types) or not teamarea_name:
excp_msg = "Please specify a valid TeamArea name"
self.log.error(excp_msg)
raise exception.BadValue(excp_msg)
self.log.debug("Try to get <TeamArea %s>", teama... | def getTeamArea(self, teamarea_name, projectarea_id=None,
projectarea_name=None, archived=False,
returned_properties=None) | Get :class:`rtcclient.models.TeamArea` object by its name
If `projectarea_id` or `projectarea_name` is
specified, then the matched :class:`rtcclient.models.TeamArea`
in that project area will be returned.
Otherwise, only return the first found
:class:`rtcclient.models.TeamArea` ... | 2.238436 | 2.288724 | 0.978028 |
return self._getTeamAreas(projectarea_id=projectarea_id,
projectarea_name=projectarea_name,
archived=archived,
returned_properties=returned_properties) | def getTeamAreas(self, projectarea_id=None, projectarea_name=None,
archived=False, returned_properties=None) | Get all :class:`rtcclient.models.TeamArea` objects by
project area id or name
If both `projectarea_id` and `projectarea_name` are `None`,
all team areas in all project areas will be returned.
If no :class:`rtcclient.models.TeamArea` objects are retrieved,
`None` is returned.
... | 1.988484 | 2.475863 | 0.803148 |
if not isinstance(plannedfor_name,
six.string_types) or not plannedfor_name:
excp_msg = "Please specify a valid PlannedFor name"
self.log.error(excp_msg)
raise exception.BadValue(excp_msg)
self.log.debug("Try to get <PlannedFor %s>... | def getPlannedFor(self, plannedfor_name, projectarea_id=None,
projectarea_name=None, archived=False,
returned_properties=None) | Get :class:`rtcclient.models.PlannedFor` object by its name
:param plannedfor_name: the plannedfor name
:param projectarea_id: the :class:`rtcclient.project_area.ProjectArea`
id
:param projectarea_name: the project area name
:param archived: (default is False) whether the pl... | 2.332651 | 2.413287 | 0.966587 |
return self._getPlannedFors(projectarea_id=projectarea_id,
projectarea_name=projectarea_name,
archived=archived,
returned_properties=returned_properties) | def getPlannedFors(self, projectarea_id=None, projectarea_name=None,
archived=False, returned_properties=None) | Get all :class:`rtcclient.models.PlannedFor` objects by
project area id or name
If both `projectarea_id` and `projectarea_name` are None,
all the plannedfors in all project areas will be returned.
If no :class:`rtcclient.models.PlannedFor` objecs are retrieved,
`None` is return... | 1.76006 | 2.17826 | 0.808012 |
self.log.debug("Try to get <Severity %s>", severity_name)
if not isinstance(severity_name,
six.string_types) or not severity_name:
excp_msg = "Please specify a valid Severity name"
self.log.error(excp_msg)
raise exception.BadValue(e... | def getSeverity(self, severity_name, projectarea_id=None,
projectarea_name=None) | Get :class:`rtcclient.models.Severity` object by its name
At least either of `projectarea_id` and `projectarea_name` is given
:param severity_name: the severity name
:param projectarea_id: the :class:`rtcclient.project_area.ProjectArea`
id
:param projectarea_name: the proje... | 2.558986 | 2.519518 | 1.015665 |
return self._getSeverities(projectarea_id=projectarea_id,
projectarea_name=projectarea_name) | def getSeverities(self, projectarea_id=None, projectarea_name=None) | Get all :class:`rtcclient.models.Severity` objects by
project area id or name
At least either of `projectarea_id` and `projectarea_name` is given
If no :class:`rtcclient.models.Severity` is retrieved,
`None` is returned.
:param projectarea_id: the :class:`rtcclient.project_are... | 2.725537 | 3.349394 | 0.81374 |
self.log.debug("Try to get <Priority %s>", priority_name)
if not isinstance(priority_name,
six.string_types) or not priority_name:
excp_msg = "Please specify a valid Priority name"
self.log.error(excp_msg)
raise exception.BadValue(e... | def getPriority(self, priority_name, projectarea_id=None,
projectarea_name=None) | Get :class:`rtcclient.models.Priority` object by its name
At least either of `projectarea_id` and `projectarea_name` is given
:param priority_name: the priority name
:param projectarea_id: the :class:`rtcclient.project_area.ProjectArea`
id
:param projectarea_name: the proje... | 2.499793 | 2.512761 | 0.994839 |
return self._getPriorities(projectarea_id=projectarea_id,
projectarea_name=projectarea_name) | def getPriorities(self, projectarea_id=None, projectarea_name=None) | Get all :class:`rtcclient.models.Priority` objects by
project area id or name
At least either of `projectarea_id` and `projectarea_name` is given.
If no :class:`rtcclient.models.Priority` is retrieved,
`None` is returned.
:param projectarea_id: the :class:`rtcclient.project_ar... | 2.804249 | 3.730141 | 0.751781 |
self.log.debug("Try to get <FoundIn %s>", foundin_name)
if not isinstance(foundin_name,
six.string_types) or not foundin_name:
excp_msg = "Please specify a valid PlannedFor name"
self.log.error(excp_msg)
raise exception.BadValue(exc... | def getFoundIn(self, foundin_name, projectarea_id=None,
projectarea_name=None, archived=False) | Get :class:`rtcclient.models.FoundIn` object by its name
:param foundin_name: the foundin name
:param projectarea_id: the :class:`rtcclient.project_area.ProjectArea`
id
:param projectarea_name: the project area name
:param archived: (default is False) whether the foundin is ... | 2.507356 | 2.453832 | 1.021812 |
return self._getFoundIns(projectarea_id=projectarea_id,
projectarea_name=projectarea_name,
archived=archived) | def getFoundIns(self, projectarea_id=None, projectarea_name=None,
archived=False) | Get all :class:`rtcclient.models.FoundIn` objects by
project area id or name
If both `projectarea_id` and `projectarea_name` are `None`,
all the foundins in all project areas will be returned.
If no :class:`rtcclient.models.FoundIn` objects are retrieved,
`None` is returned.
... | 2.141468 | 2.664752 | 0.803628 |
self.log.debug("Try to get <FiledAgainst %s>", filedagainst_name)
if not isinstance(filedagainst_name,
six.string_types) or not filedagainst_name:
excp_msg = "Please specify a valid FiledAgainst name"
self.log.error(excp_msg)
raise ... | def getFiledAgainst(self, filedagainst_name, projectarea_id=None,
projectarea_name=None, archived=False) | Get :class:`rtcclient.models.FiledAgainst` object by its name
:param filedagainst_name: the filedagainst name
:param projectarea_id: the :class:`rtcclient.project_area.ProjectArea`
id
:param projectarea_name: the project area name
:param archived: (default is False) whether ... | 2.338064 | 2.304191 | 1.014701 |
return self._getFiledAgainsts(projectarea_id=projectarea_id,
projectarea_name=projectarea_name,
archived=archived) | def getFiledAgainsts(self, projectarea_id=None, projectarea_name=None,
archived=False) | Get all :class:`rtcclient.models.FiledAgainst` objects by
project area id or name
If both `projectarea_id` and `projectarea_name` are `None`,
all the filedagainsts in all project areas will be returned.
If no :class:`rtcclient.models.FiledAgainst` objects are retrieved,
`None` ... | 2.056008 | 2.605184 | 0.789199 |
return self.templater.getTemplate(copied_from,
template_name=template_name,
template_folder=template_folder,
keep=keep,
encoding=encod... | def getTemplate(self, copied_from, template_name=None,
template_folder=None, keep=False, encoding="UTF-8") | Get template from some to-be-copied workitems
More details, please refer to
:class:`rtcclient.template.Templater.getTemplate` | 2.14516 | 2.246697 | 0.954806 |
self.templater.getTemplates(workitems,
template_folder=template_folder,
template_names=template_names,
keep=keep,
encoding=encoding) | def getTemplates(self, workitems, template_folder=None,
template_names=None, keep=False, encoding="UTF-8") | Get templates from a group of to-be-copied workitems
and write them to files named after the names in `template_names`
respectively.
More details, please refer to
:class:`rtcclient.template.Templater.getTemplates` | 2.281194 | 2.489652 | 0.916271 |
return self.templater.listFieldsFromWorkitem(copied_from,
keep=keep) | def listFieldsFromWorkitem(self, copied_from, keep=False) | List all the attributes to be rendered directly from some
to-be-copied workitems
More details, please refer to
:class:`rtcclient.template.Templater.listFieldsFromWorkitem` | 6.548436 | 5.554345 | 1.178975 |
try:
if isinstance(workitem_id, bool):
raise ValueError("Invalid Workitem id")
if isinstance(workitem_id, six.string_types):
workitem_id = int(workitem_id)
if not isinstance(workitem_id, int):
raise ValueError("Invalid... | def getWorkitem(self, workitem_id, returned_properties=None) | Get :class:`rtcclient.workitem.Workitem` object by its id/number
:param workitem_id: the workitem id/number
(integer or equivalent string)
:param returned_properties: the returned properties that you want.
Refer to :class:`rtcclient.client.RTCClient` for more explanations
... | 2.838937 | 2.805921 | 1.011767 |
workitems_list = list()
projectarea_ids = list()
if not isinstance(projectarea_id,
six.string_types) or not projectarea_id:
pa_ids = self.getProjectAreaIDs(projectarea_name)
if pa_ids is None:
self.log.warning("Stop gett... | def getWorkitems(self, projectarea_id=None, projectarea_name=None,
returned_properties=None, archived=False) | Get all :class:`rtcclient.workitem.Workitem` objects by
project area id or name
If both `projectarea_id` and `projectarea_name` are `None`,
all the workitems in all project areas will be returned.
If no :class:`rtcclient.workitem.Workitem` objects are retrieved,
`None` is retur... | 3.372389 | 3.389767 | 0.994873 |
if not isinstance(projectarea_id,
six.string_types) or not projectarea_id:
projectarea = self.getProjectArea(projectarea_name)
projectarea_id = projectarea.id
else:
projectarea = self.getProjectAreaByID(projectarea_id)
item... | def createWorkitem(self, item_type, title, description=None,
projectarea_id=None, projectarea_name=None,
template=None, copied_from=None, keep=False,
**kwargs) | Create a workitem
:param item_type: the type of the workitem
(e.g. task/defect/issue)
:param title: the title of the new created workitem
:param description: the description of the new created workitem
:param projectarea_id: the :class:`rtcclient.project_area.ProjectArea`
... | 3.568729 | 3.535327 | 1.009448 |
copied_wi = self.getWorkitem(copied_from)
if title is None:
title = copied_wi.title
if prefix is not None:
title = prefix + title
if description is None:
description = copied_wi.description
if prefix is not None:
... | def copyWorkitem(self, copied_from, title=None, description=None,
prefix=None) | Create a workitem by copying from an existing one
:param copied_from: the to-be-copied workitem id
:param title: the new workitem title/summary.
If `None`, will copy that from a to-be-copied workitem
:param description: the new workitem description.
If `None`, will copy ... | 3.968409 | 4.050307 | 0.97978 |
parameters = self.listFields(template)
self._findMissingParams(parameters, **kwargs) | def _checkMissingParams(self, template, **kwargs) | Check the missing parameters for rendering from the template file | 9.915775 | 9.108602 | 1.088617 |
parameters = self.listFieldsFromWorkitem(copied_from,
keep=keep)
self._findMissingParams(parameters, **kwargs) | def _checkMissingParamsFromWorkitem(self, copied_from, keep=False,
**kwargs) | Check the missing parameters for rendering directly from the
copied workitem | 6.273519 | 6.781738 | 0.925061 |
self.log.debug("Checking the validity of workitem type: %s",
item_type)
try:
project_area = self.getProjectAreaByID(projectarea_id)
if project_area.getItemType(item_type):
return True
else:
return False
... | def checkType(self, item_type, projectarea_id) | Check the validity of :class:`rtcclient.workitem.Workitem` type
:param item_type: the type of the workitem
(e.g. Story/Defect/Epic)
:param projectarea_id: the :class:`rtcclient.project_area.ProjectArea`
id
:return: `True` or `False`
:rtype: bool | 4.180271 | 3.367675 | 1.241293 |
if projectarea_url is not None:
try:
if (entry.get("rtc_cm:projectArea")
.get("@rdf:resource")) != projectarea_url:
return None
except AttributeError:
pass
if filter_rule is not None:
... | def _handle_resource_entry(self, resource_name, entry,
projectarea_url=None, archived=False,
filter_rule=None) | :param filter_rule: a list of filter rules
e.g. filter_rule = [("dc:creator", "@rdf:resource",
"https://test.url:9443/jts/users/me%40mail"),
("dc:modified", None,
"2013-08-28T02:06:26.516Z")
... | 3.351319 | 3.124874 | 1.072465 |
rp = returned_properties
return self.query.queryWorkitems(query_str=query_str,
projectarea_id=projectarea_id,
projectarea_name=projectarea_name,
returned_properties=rp,
... | def queryWorkitems(self, query_str, projectarea_id=None,
projectarea_name=None, returned_properties=None,
archived=False) | Query workitems with the query string in a certain project area
At least either of `projectarea_id` and `projectarea_name` is given
:param query_str: a valid query string
:param projectarea_id: the :class:`rtcclient.project_area.ProjectArea`
id
:param projectarea_name: the ... | 2.42221 | 3.014242 | 0.803589 |
# check the validity of comment id
try:
if isinstance(comment_id, bool):
raise ValueError()
if isinstance(comment_id, six.string_types):
comment_id = int(comment_id)
if not isinstance(comment_id, int):
raise Va... | def getCommentByID(self, comment_id) | Get the :class:`rtcclient.models.Comment` object by its id
Note: the comment id starts from 0
:param comment_id: the comment id (integer or equivalent string)
:return: the :class:`rtcclient.models.Comment` object
:rtype: rtcclient.models.Comment | 3.763299 | 3.437676 | 1.094722 |
origin_comment = '''
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rtc_ext="http://jazz.net/xmlns/prod/jazz/rtc/ext/1.0/"
xmlns:rtc_cm="http://jazz.net/xmlns/prod/jazz/rtc/cm/1.0/"
xmlns:oslc_cm="http://open-services.net/ns/cm#"
xmlns:dcterms="http://purl.o... | def addComment(self, msg=None) | Add a comment to this workitem
:param msg: comment message
:return: the :class:`rtcclient.models.Comment` object
:rtype: rtcclient.models.Comment | 2.572892 | 2.47137 | 1.041079 |
headers, raw_data = self._perform_subscribe()
existed_flag, raw_data = self._add_subscriber(email, raw_data)
if existed_flag:
return
self._update_subscribe(headers, raw_data)
self.log.info("Successfully add a subscriber: %s for <Workitem %s>",
... | def addSubscriber(self, email) | Add a subscriber to this workitem
If the subscriber has already been added, no more actions will be
performed.
:param email: the subscriber's email | 8.658772 | 7.382711 | 1.172844 |
if not hasattr(emails_list, "__iter__"):
error_msg = "Input parameter 'emails_list' is not iterable"
self.log.error(error_msg)
raise exception.BadValue(error_msg)
# overall flag
existed_flags = False
headers, raw_data = self._perform_subscr... | def addSubscribers(self, emails_list) | Add subscribers to this workitem
If the subscribers have already been added, no more actions will be
performed.
:param emails_list: a :class:`list`/:class:`tuple`/:class:`set`
contains the the subscribers' emails | 4.470097 | 4.282473 | 1.043812 |
headers, raw_data = self._perform_subscribe()
missing_flag, raw_data = self._remove_subscriber(email, raw_data)
if missing_flag:
return
self._update_subscribe(headers, raw_data)
self.log.info("Successfully remove a subscriber: %s for <Workitem %s>",
... | def removeSubscriber(self, email) | Remove a subscriber from this workitem
If the subscriber has not been added, no more actions will be
performed.
:param email: the subscriber's email | 8.849577 | 7.714882 | 1.147079 |
if not hasattr(emails_list, "__iter__"):
error_msg = "Input parameter 'emails_list' is not iterable"
self.log.error(error_msg)
raise exception.BadValue(error_msg)
# overall flag
missing_flags = True
headers, raw_data = self._perform_subscri... | def removeSubscribers(self, emails_list) | Remove subscribers from this workitem
If the subscribers have not been added, no more actions will be
performed.
:param emails_list: a :class:`list`/:class:`tuple`/:class:`set`
contains the the subscribers' emails | 4.277019 | 4.134819 | 1.034391 |
self.log.debug("Try to get <Action %s>", action_name)
if not isinstance(action_name, six.string_types) or not action_name:
excp_msg = "Please specify a valid action name"
self.log.error(excp_msg)
raise exception.BadValue(excp_msg)
actions = self._ge... | def getAction(self, action_name) | Get the :class:`rtcclient.models.Action` object by its name
:param action_name: the name/title of the action
:return: the :class:`rtcclient.models.Action` object
:rtype: rtcclient.models.Action | 2.871293 | 2.741026 | 1.047525 |
cust_attr = (self.raw_data.get("rtc_cm:state")
.get("@rdf:resource")
.split("/")[-2])
return self.rtc_obj._get_paged_resources("State",
projectarea_id=self.contextId,
... | def getStates(self) | Get all :class:`rtcclient.models.State` objects of this workitem
:return: a :class:`list` contains all the
:class:`rtcclient.models.State` objects
:rtype: list | 17.947863 | 13.3354 | 1.345881 |
build_tag = ("rtc_cm:com.ibm.team.build.linktype.includedWorkItems."
"com.ibm.team.build.common.link.includedInBuilds")
return self.rtc_obj._get_paged_resources("IncludedInBuild",
workitem_id=self.identifier,
... | def getIncludedInBuilds(self) | Get all :class:`rtcclient.models.IncludedInBuild` objects that
have already included this workitem
WARNING: If one of the IncludedInBuilds is removed or cannot be
retrieved/found correctly, then 404 error will be raised.
:return: a :class:`list` contains all the
:class:`rtc... | 16.602232 | 12.464408 | 1.331971 |
parent_tag = ("rtc_cm:com.ibm.team.workitem.linktype."
"parentworkitem.parent")
rp = returned_properties
parent = (self.rtc_obj
._get_paged_resources("Parent",
workitem_id=self.identifier,
... | def getParent(self, returned_properties=None) | Get the parent workitem of this workitem
If no parent, None will be returned.
:param returned_properties: the returned properties that you want.
Refer to :class:`rtcclient.client.RTCClient` for more explanations
:return: a :class:`rtcclient.workitem.Workitem` object
:rtype:... | 11.733963 | 10.37027 | 1.1315 |
children_tag = ("rtc_cm:com.ibm.team.workitem.linktype."
"parentworkitem.children")
rp = returned_properties
return (self.rtc_obj
._get_paged_resources("Children",
workitem_id=self.identifier,
... | def getChildren(self, returned_properties=None) | Get all the children workitems of this workitem
If no children, None will be returned.
:param returned_properties: the returned properties that you want.
Refer to :class:`rtcclient.client.RTCClient` for more explanations
:return: a :class:`rtcclient.workitem.Workitem` object
... | 13.87401 | 11.428967 | 1.213934 |
changeset_tag = ("rtc_cm:com.ibm.team.filesystem.workitems."
"change_set.com.ibm.team.scm.ChangeSet")
return (self.rtc_obj
._get_paged_resources("ChangeSet",
workitem_id=self.identifier,
... | def getChangeSets(self) | Get all the ChangeSets of this workitem
:return: a :class:`list` contains all the
:class:`rtcclient.models.ChangeSet` objects
:rtype: list | 14.561218 | 11.901298 | 1.223498 |
if isinstance(parent_id, bool):
raise exception.BadValue("Please input a valid workitem id")
if isinstance(parent_id, six.string_types):
parent_id = int(parent_id)
if not isinstance(parent_id, int):
raise exception.BadValue("Please input a valid work... | def addParent(self, parent_id) | Add a parent to current workitem
Notice: for a certain workitem, no more than one parent workitem
can be added and specified
:param parent_id: the parent workitem id/number
(integer or equivalent string) | 3.812927 | 3.585835 | 1.06333 |
self.log.debug("Try to add a child <Workitem %s> to current "
"<Workitem %s>",
child_id,
self)
self._addChildren([child_id])
self.log.info("Successfully add a child <Workitem %s> to current "
"<W... | def addChild(self, child_id) | Add a child to current workitem
:param child_id: the child workitem id/number
(integer or equivalent string) | 4.300728 | 3.259772 | 1.319334 |
if not hasattr(child_ids, "__iter__"):
error_msg = "Input parameter 'child_ids' is not iterable"
self.log.error(error_msg)
raise exception.BadValue(error_msg)
self.log.debug("Try to add children <Workitem %s> to current "
"<Workitem %... | def addChildren(self, child_ids) | Add children to current workitem
:param child_ids: a :class:`list` contains the children
workitem id/number (integer or equivalent string) | 3.421973 | 2.913308 | 1.1746 |
self.log.debug("Try to remove the parent workitem from current "
"<Workitem %s>",
self)
headers = copy.deepcopy(self.rtc_obj.headers)
headers["Content-Type"] = self.OSLC_CR_JSON
req_url = "".join([self.url,
... | def removeParent(self) | Remove the parent workitem from current workitem
Notice: for a certain workitem, no more than one parent workitem
can be added and specified | 5.914475 | 5.094352 | 1.160987 |
self.log.debug("Try to remove a child <Workitem %s> from current "
"<Workitem %s>",
child_id,
self)
self._removeChildren([child_id])
self.log.info("Successfully remove a child <Workitem %s> from "
... | def removeChild(self, child_id) | Remove a child from current workitem
:param child_id: the child workitem id/number
(integer or equivalent string) | 4.415029 | 3.334604 | 1.324004 |
if not hasattr(child_ids, "__iter__"):
error_msg = "Input parameter 'child_ids' is not iterable"
self.log.error(error_msg)
raise exception.BadValue(error_msg)
self.log.debug("Try to remove children <Workitem %s> from current "
"<Worki... | def removeChildren(self, child_ids) | Remove children from current workitem
:param child_ids: a :class:`list` contains the children
workitem id/number (integer or equivalent string) | 3.523187 | 2.928138 | 1.203217 |
proj_id = self.contextId
fa = self.rtc_obj.getFiledAgainst(self.filedAgainst,
projectarea_id=proj_id)
fa_id = fa.url.split("/")[-1]
headers = copy.deepcopy(self.rtc_obj.headers)
if headers.__contains__("Content-Type"):
... | def addAttachment(self, filepath) | Upload attachment to a workitem
:param filepath: the attachment file path
:return: the :class:`rtcclient.models.Attachment` object
:rtype: rtcclient.models.Attachment | 4.428782 | 4.32116 | 1.024906 |
attachment_tag = ("rtc_cm:com.ibm.team.workitem.linktype."
"attachment.attachment")
return (self.rtc_obj
._get_paged_resources("Attachment",
workitem_id=self.identifier,
... | def getAttachments(self) | Get all :class:`rtcclient.models.Attachment` objects of
this workitem
:return: a :class:`list` contains all the
:class:`rtcclient.models.Attachment` objects
:rtype: list | 18.473385 | 13.88889 | 1.330084 |
if config_path:
if not os.path.exists(config_path):
return tuple()
try:
entries = _lxc.list_containers(active=active, defined=defined,
config_path=config_path)
except ValueError:
return tuple()
else:
... | def list_containers(active=True, defined=True,
as_object=False, config_path=None) | List the containers on the system. | 2.174251 | 2.210029 | 0.983811 |
if isinstance(cmd, tuple):
return _lxc.attach_run_command(cmd)
elif isinstance(cmd, list):
return _lxc.attach_run_command((cmd[0], cmd))
else:
return _lxc.attach_run_command((cmd, [cmd])) | def attach_run_command(cmd) | Run a command when attaching
Please do not call directly, this will execvp the command.
This is to be used in conjunction with the attach method
of a container. | 2.839604 | 3.170966 | 0.895501 |
if isinstance(arch, bytes):
arch = unicode(arch)
return _lxc.arch_to_personality(arch) | def arch_to_personality(arch) | Determine the process personality corresponding to the architecture | 6.324957 | 6.278669 | 1.007372 |
if not self.running:
return False
if os.path.exists("/sys/class/net/%s/phy80211/name" % name):
with open("/sys/class/net/%s/phy80211/name" % name) as fd:
phy = fd.read().strip()
if subprocess.call(['iw', 'phy', phy, 'set', 'netns',
... | def add_device_net(self, name, destname=None) | Add network device to running container. | 3.148842 | 3.140585 | 1.002629 |
return _lxc.Container.set_config_item(self, key, value) | def append_config_item(self, key, value) | Append 'value' to 'key', assuming 'key' is a list.
If 'key' isn't a list, 'value' will be set as the value of 'key'. | 9.262669 | 8.568601 | 1.081001 |
if isinstance(args, dict):
template_args = []
for item in args.items():
template_args.append("--%s" % item[0])
template_args.append("%s" % item[1])
else:
template_args = args
if template:
return _lxc.Conta... | def create(self, template=None, flags=0, args=()) | Create a new rootfs for the container.
"template" if passed must be a valid template name.
"flags" (optional) is an integer representing the optional
create flags to be passed.
"args" (optional) is a tuple of arguments to pass to the
template. It can also b... | 2.321961 | 2.225127 | 1.043518 |
args = {}
args['newname'] = newname
args['flags'] = flags
args['newsize'] = newsize
args['hookargs'] = hookargs
if config_path:
args['config_path'] = config_path
if bdevtype:
args['bdevtype'] = bdevtype
if bdevdata:
... | def clone(self, newname, config_path=None, flags=0, bdevtype=None,
bdevdata=None, newsize=0, hookargs=()) | Clone the current container. | 2.048701 | 1.968412 | 1.040789 |
if not self.running:
return False
return _lxc.Container.console(self, ttynum, stdinfd, stdoutfd,
stderrfd, escape) | def console(self, ttynum=-1, stdinfd=0, stdoutfd=1, stderrfd=2, escape=1) | Attach to console of running container. | 4.629041 | 4.610362 | 1.004051 |
if not self.running:
return False
return _lxc.Container.console_getfd(self, ttynum) | def console_getfd(self, ttynum=-1) | Attach to console of running container. | 7.216484 | 6.013214 | 1.200104 |
value = _lxc.Container.get_cgroup_item(self, key)
if value is False:
return False
else:
return value.rstrip("\n") | def get_cgroup_item(self, key) | Returns the value for a given cgroup entry.
A list is returned when multiple values are set. | 6.113016 | 5.873336 | 1.040808 |
value = _lxc.Container.get_config_item(self, key)
if value is False:
return False
elif value.endswith("\n"):
return value.rstrip("\n").split("\n")
else:
return value | def get_config_item(self, key) | Returns the value for a given config key.
A list is returned when multiple values are set. | 4.865798 | 4.620878 | 1.053003 |
if key:
value = _lxc.Container.get_keys(self, key)
else:
value = _lxc.Container.get_keys(self)
if value is False:
return False
elif value.endswith("\n"):
return value.rstrip("\n").split("\n")
else:
return value | def get_keys(self, key=None) | Returns a list of valid sub-keys. | 3.421779 | 3.196185 | 1.070582 |
kwargs = {}
if interface:
kwargs['interface'] = interface
if family:
kwargs['family'] = family
if scope:
kwargs['scope'] = scope
ips = None
timeout = int(os.environ.get('LXC_GETIP_TIMEOUT', timeout))
while not ips:
... | def get_ips(self, interface=None, family=None, scope=None, timeout=0) | Get a tuple of IPs for the container. | 2.748636 | 2.768832 | 0.992706 |
if _lxc.Container.rename(self, new_name):
return Container(new_name)
return False | def rename(self, new_name) | Rename the container.
On success, returns the new Container object.
On failure, returns False. | 9.585354 | 6.839241 | 1.401523 |
try:
old_value = self.get_config_item(key)
except KeyError:
old_value = None
# Get everything to unicode with python2
if isinstance(value, str):
value = value.decode()
elif isinstance(value, list):
for i in range(len(value... | def set_config_item(self, key, value) | Set a config key to a provided value.
The value can be a list for the keys supporting multiple values. | 2.496075 | 2.47679 | 1.007786 |
if isinstance(state, str):
state = state.upper()
return _lxc.Container.wait(self, state, timeout) | def wait(self, state, timeout=-1) | Wait for the container to reach a given state or timeout. | 5.866615 | 5.001238 | 1.173032 |
try:
temp = self.environment.get_template(template)
return temp.render(**kwargs)
except AttributeError:
err_msg = "Invalid value for 'template'"
self.log.error(err_msg)
raise exception.BadValue(err_msg) | def render(self, template, **kwargs) | Renders the template
:param template: The template to render.
The template is actually a file, which is usually generated
by :class:`rtcclient.template.Templater.getTemplate`
and can also be modified by user accordingly.
:param kwargs: The `kwargs` dict is used to fi... | 3.862231 | 4.1882 | 0.92217 |
temp = jinja2.Template(self.getTemplate(copied_from,
template_name=None,
template_folder=None,
keep=keep,
enco... | def renderFromWorkitem(self, copied_from, keep=False,
encoding="UTF-8", **kwargs) | Render the template directly from some to-be-copied
:class:`rtcclient.workitem.Workitem` without saving to a file
:param copied_from: the to-be-copied
:class:`rtcclient.workitem.Workitem` id
:param keep (default is False): If `True`, some of the below fields
will remain ... | 4.247184 | 5.04942 | 0.841123 |
try:
temp_source = self.environment.loader.get_source(self.environment,
template)
return self.listFieldsFromSource(temp_source)
except AttributeError:
err_msg = "Invalid value for 'template'"
... | def listFields(self, template) | List all the attributes to be rendered from the template file
:param template: The template to render.
The template is actually a file, which is usually generated
by :class:`rtcclient.template.Templater.getTemplate` and can also
be modified by user accordingly.
:retu... | 4.66007 | 4.551599 | 1.023831 |
temp_source = self.getTemplate(copied_from,
template_name=None,
template_folder=None,
keep=keep)
return self.listFieldsFromSource(temp_source) | def listFieldsFromWorkitem(self, copied_from, keep=False) | List all the attributes to be rendered directly from some
to-be-copied :class:`rtcclient.workitem.Workitem`
:param copied_from: the to-be-copied
:class:`rtcclient.workitem.Workitem` id
:param keep: (default is False) If `True`, some of below parameters
(which will not be... | 6.024301 | 6.479643 | 0.929727 |
ast = self.environment.parse(template_source)
return jinja2.meta.find_undeclared_variables(ast) | def listFieldsFromSource(self, template_source) | List all the attributes to be rendered directly from template
source
:param template_source: the template source (usually represents the
template content in string format)
:return: a :class:`set` contains all the needed attributes
:rtype: set | 5.629951 | 6.067139 | 0.927942 |
match_str_list = ["rtc_cm:com.ibm.",
"calm:"]
for key in wk_raw_data.keys():
for match_str in match_str_list:
if key.startswith(match_str):
try:
wk_raw_data.pop(key)
self.l... | def _remove_long_fields(self, wk_raw_data) | Remove long fields: These fields are can only customized after
the workitems are created | 4.500037 | 4.239264 | 1.061514 |
if (not workitems or isinstance(workitems, six.string_types) or
isinstance(workitems, int) or
isinstance(workitems, float) or
not hasattr(workitems, "__iter__")):
error_msg = "Input parameter 'workitems' is not iterable"
self.log.... | def getTemplates(self, workitems, template_folder=None,
template_names=None, keep=False, encoding="UTF-8") | Get templates from a group of to-be-copied :class:`Workitems` and
write them to files named after the names in `template_names`
respectively.
:param workitems: a :class:`list`/:class:`tuple`/:class:`set`
contains the ids (integer or equivalent string) of some
to-be-copie... | 2.018536 | 2.025638 | 0.996494 |
identifier = self.url.split("/")[-1]
resource_url = "/".join(["%s" % self.rtc_obj.url,
"resource/itemOid",
"com.ibm.team.scm.ChangeSet",
"%s?_mediaType=text/xml" % identifier])
resp = sel... | def getChanges(self) | Get all :class:`rtcclient.models.Change` objects in this changeset
:return: a :class:`list` contains all the
:class:`rtcclient.models.Change` objects
:rtype: list | 5.058253 | 4.692071 | 1.078043 |
if u"true" == self.before:
self.log.info("This file is newly added. No previous file")
else:
self.log.info("Fetching initial file of this Change<%s>:" % self)
return self._fetchFile(self.before, file_folder, override=False) | def fetchBeforeStateFile(self, file_folder) | Fetch the initial file (before the change) to a folder
If the file is newly added, then `None` will be returned.
:param file_folder: the folder to store the file
:return: the :class:`string` object
:rtype: string | 12.23789 | 9.372498 | 1.305723 |
if u"true" == self.after:
self.log.info("This file has been deleted successfully.")
else:
self.log.info("Fetching final file of this Change<%s>:" % self)
return self._fetchFile(self.after, file_folder) | def fetchAfterStateFile(self, file_folder) | Fetch the final file (after the change) to a folder
If the file has been deleted, then `None` will be returned.
:param file_folder: the folder to store the file
:return: the :class:`string` object
:rtype: string | 12.047946 | 8.800661 | 1.368982 |
if not table: raise ValueError("no table")
print('------- dumping table {}'.format(table))
pipes = ["gzip"]
outfile_path = self._get_outfile_path(table)
cmd = self._get_args(
"pg_dump",
"--table={}".format(table),
#"--data-only",
... | def table_dump(self, table) | dump all the rows of the given table name | 4.140374 | 4.115107 | 1.00614 |
'''
return an opened tempfile pointer that can be used
http://docs.python.org/2/library/tempfile.html
'''
f = tempfile.NamedTemporaryFile(delete=False)
self.tmp_files.add(f.name)
return f | def _get_file(self) | return an opened tempfile pointer that can be used
http://docs.python.org/2/library/tempfile.html | 5.595342 | 2.267657 | 2.467455 |
args = list(args)
args.insert(0, executable)
if self.username:
args.append("--username={}".format(self.username))
if self.host:
args.append("--host={}".format(self.host))
if self.port:
args.append("--port={}".format(self.port))
... | def _get_args(self, executable, *args) | compile all the executable and the arguments, combining with common arguments
to create a full batch of command args | 2.28907 | 2.267604 | 1.009467 |
self.outfile_count += 1
outfile = os.path.join(self.directory, '{:03d}_{}.sql.gz'.format(self.outfile_count, table))
return outfile | def _get_outfile_path(self, table) | return the path for a file we can use to back up the table | 3.766044 | 3.228677 | 1.166436 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.