code
stringlengths
52
7.75k
docs
stringlengths
1
5.85k
def delete(self, photo_id, album_id=0): if isinstance(photo_id, Info): photo_id = photo_id.id return self._session.okc_post('photoupload', data={ 'albumid': album_id, 'picid': photo_id, 'authcode': self._authcode, 'picture.delete_ajax'...
Delete a photo from the logged in users account. :param photo_id: The okcupid id of the photo to delete. :param album_id: The album from which to delete the photo.
def add_command_line_options(add_argument, use_short_options=True): logger_args = ("--enable-logger",) credentials_args = ("--credentials",) if use_short_options: logger_args += ('-l',) credentials_args += ('-c',) add_argument(*logger_args, dest='enabled_loggers', a...
:param add_argument: The add_argument method of an ArgParser. :param use_short_options: Whether or not to add short options.
def handle_command_line_options(args): for enabled_log in args.enabled_loggers: enable_logger(enabled_log) for credential_file in args.credential_files: settings.load_credentials_from_filepath(credential_file) if args.echo: from okcupyd import db db.echo = True d...
:param args: The args returned from an ArgParser
def IndexedREMap(*re_strings, **kwargs): default = kwargs.get('default', 0) offset = kwargs.get('offset', 1) string_index_pairs = [] for index, string_or_tuple in enumerate(re_strings, offset): if isinstance(string_or_tuple, six.string_types): string_or_tuple = (string_or_tuple,...
Build a :class:`~.REMap` from the provided regular expression string. Each string will be associated with the index corresponding to its position in the argument list. :param re_strings: The re_strings that will serve as keys in the map. :param default: The value to return if none of the regular expres...
def bust_self(self, obj): if self.func.__name__ in obj.__dict__: delattr(obj, self.func.__name__)
Remove the value that is being stored on `obj` for this :class:`.cached_property` object. :param obj: The instance on which to bust the cache.
def bust_caches(cls, obj, excludes=()): for name, _ in cls.get_cached_properties(obj): if name in obj.__dict__ and not name in excludes: delattr(obj, name)
Bust the cache for all :class:`.cached_property` objects on `obj` :param obj: The instance on which to bust the caches.
def from_string_pairs(cls, string_value_pairs, **kwargs): return cls(re_value_pairs=[(re.compile(s), v) for s, v in string_value_pairs], **kwargs)
Build an :class:`~.REMap` from str, value pairs by applying `re.compile` to each string and calling the __init__ of :class:`~.REMap`
def __get_dbms_version(self, make_connection=True): if not self.connection and make_connection: self.connect() with self.connection.cursor() as cursor: cursor.execute("SELECT SERVERPROPERTY('productversion')") return cursor.fetchone()[0]
Returns the 'DBMS Version' string, or ''. If a connection to the database has not already been established, a connection will be made when `make_connection` is True.
def sender(self): return (self._message_thread.user_profile if 'from_me' in self._message_element.attrib['class'] else self._message_thread.correspondent_profile)
:returns: A :class:`~okcupyd.profile.Profile` instance belonging to the sender of this message.
def recipient(self): return (self._message_thread.correspondent_profile if 'from_me' in self._message_element.attrib['class'] else self._message_thread.user_profile)
:returns: A :class:`~okcupyd.profile.Profile` instance belonging to the recipient of this message.
def content(self): # The code that follows is obviously pretty disgusting. # It seems like it might be impossible to completely replicate # the text of the original message if it has trailing whitespace message = self._content_xpb.one_(self._message_element) first_line =...
:returns: The text body of the message.
def delete_threads(cls, session, thread_ids_or_threads, authcode=None): thread_ids = [thread.id if isinstance(thread, cls) else thread for thread in thread_ids_or_threads] if not authcode: authcode = helpers.get_authcode(html.fromstring( session...
:param session: A logged in :class:`~okcupyd.session.Session`. :param thread_ids_or_threads: A list whose members are either :class:`~.MessageThread` instances or okc_ids of message threads. :param authcode: Authcode to use for ...
def correspondent_id(self): try: return int(self._thread_element.attrib['data-personid']) except (ValueError, KeyError): try: return int(self.correspondent_profile.id) except: pass
:returns: The id assigned to the correspondent of this message.
def correspondent(self): try: return self._correspondent_xpb.one_(self._thread_element).strip() except IndexError: raise errors.NoCorrespondentError()
:returns: The username of the user with whom the logged in user is conversing in this :class:`~.MessageThread`.
def got_response(self): return any(message.sender != self.initiator for message in self.messages)
:returns: Whether or not the :class:`~.MessageThread`. has received a response.
def get_answer_id_for_question(self, question): assert question.id == self.id for answer_option in self.answer_options: if answer_option.text == question.their_answer: return answer_option.id
Get the answer_id corresponding to the answer given for question by looking at this :class:`~.UserQuestion`'s answer_options. The given :class:`~.Question` instance must have the same id as this :class:`~.UserQuestion`. That this method exists is admittedly somewhat weird. Unfortunately...
def answer_options(self): return [ AnswerOption(element) for element in self._answer_option_xpb.apply_( self._question_element ) ]
:returns: A list of :class:`~.AnswerOption` instances representing the available answers to this question.
def respond_from_user_question(self, user_question, importance): user_response_ids = [option.id for option in user_question.answer_options if option.is_users] match_response_ids = [option.id for option in us...
Respond to a question in exactly the way that is described by the given user_question. :param user_question: The user question to respond with. :type user_question: :class:`.UserQuestion` :param importance: The importance that should be used in responding to t...
def respond_from_question(self, question, user_question, importance): option_index = user_question.answer_text_to_option[ question.their_answer ].id self.respond(question.id, [option_index], [option_index], importance)
Copy the answer given in `question` to the logged in user's profile. :param question: A :class:`~.Question` instance to copy. :param user_question: An instance of :class:`~.UserQuestion` that corresponds to the same question as `question`. ...
def respond(self, question_id, user_response_ids, match_response_ids, importance, note='', is_public=1, is_new=1): form_data = { 'ajax': 1, 'submit': 1, 'answer_question': 1, 'skip': 0, 'show_all': 0, 'targetid': se...
Respond to an okcupid.com question. :param question_id: The okcupid id used to identify this question. :param user_response_ids: The answer id(s) to provide to this question. :param match_response_ids: The answer id(s) that the user considers acceptable. ...
def message(self, username, message_text): # Try to reply to an existing thread. if not isinstance(username, six.string_types): username = username.username for mailbox in (self.inbox, self.outbox): for thread in mailbox: if thread.correspondent.l...
Message an okcupid user. If an existing conversation between the logged in user and the target user can be found, reply to that thread instead of starting a new one. :param username: The username of the user to which the message should be sent. :type username: s...
def search(self, **kwargs): kwargs.setdefault('gender', self.profile.gender[0]) gentation = helpers.get_default_gentation(self.profile.gender, self.profile.orientation) kwargs.setdefault('gentation', gentation) # We are no longe...
Call :func:`~okcupyd.json_search.SearchFetchable` to get a :class:`~okcupyd.util.fetchable.Fetchable` object that will lazily perform okcupid searches to provide :class:`~okcupyd.profile.Profile` objects matching the search criteria. Defaults for `gender`, `gentation`, `location` and `r...
def get_question_answer_id(self, question, fast=False, bust_questions_cache=False): if hasattr(question, 'answer_id'): # Guard to handle incoming user_question. return question.answer_id user_question = self.get_user_question( ...
Get the index of the answer that was given to `question` See the documentation for :meth:`~.get_user_question` for important caveats about the use of this function. :param question: The question whose `answer_id` should be retrieved. :type question: :class:`~okcupyd.question.BaseQuesti...
def quickmatch(self): response = self._session.okc_get('quickmatch', params={'okc_api': 1}) return Profile(self._session, response.json()['sn'])
Return a :class:`~okcupyd.profile.Profile` obtained by visiting the quickmatch page.
def SearchFetchable(session=None, **kwargs): session = session or Session.login() return util.Fetchable( SearchManager( SearchJSONFetcher(session, **kwargs), ProfileBuilder(session) ) )
Search okcupid.com with the given parameters. Parameters are registered to this function through :meth:`~okcupyd.filter.Filters.register_filter_builder` of :data:`~okcupyd.json_search.search_filters`. :returns: A :class:`~okcupyd.util.fetchable.Fetchable` of :class:`~okcupyd.profile.Profi...
def refresh(self, nice_repr=True, **kwargs): for key, value in self._kwargs.items(): kwargs.setdefault(key, value) # No real good reason to hold on to this. DONT TOUCH. self._original_iterable = self._fetcher.fetch(**kwargs) self.exhausted = False if nice_rep...
:param nice_repr: Append the repr of a list containing the items that have been fetched to this point by the fetcher. :type nice_repr: bool :param kwargs: kwargs that should be passed to the fetcher when its fetch method is called. These are merged with t...
def build_documentation_lines(self): return [ line_string for key in sorted(self.keys) for line_string in self.build_paramter_string(key) ]
Build a parameter documentation string that can appended to the docstring of a function that uses this :class:`~.Filters` instance to build filters.
def register_filter_builder(self, function, **kwargs): kwargs['transform'] = function if kwargs.get('decider'): kwargs['decide'] = kwargs.get('decider') return type('filter', (self.filter_class,), kwargs)
Register a filter function with this :class:`~.Filters` instance. This function is curried with :class:`~okcupyd.util.currying.curry` -- that is, it can be invoked partially before it is fully evaluated. This allows us to pass kwargs to this function when it is used as a decorator: ...
def get_locid(session, location): locid = 0 query_parameters = { 'func': 'query', 'query': location, } loc_query = session.get('http://www.okcupid.com/locquery', params=query_parameters) p = html.fromstring(loc_query.content.decode('utf8')) js = l...
Make a request to locquery resource to translate a string location search into an int locid. Returns ---------- int An int that OKCupid maps to a particular geographical location.
def format_last_online(last_online): if isinstance(last_online, str): if last_online.lower() in ('day', 'today'): last_online_int = 86400 # 3600 * 24 elif last_online.lower() == 'week': last_online_int = 604800 # 3600 * 24 * 7 elif last_online.lower() == 'month...
Return the upper limit in seconds that a profile may have been online. If last_online is an int, return that int. Otherwise if last_online is a str, convert the string into an int. Returns ---------- int
def update_looking_for(profile_tree, looking_for): div = profile_tree.xpath("//div[@id = 'what_i_want']")[0] looking_for['gentation'] = div.xpath(".//li[@id = 'ajax_gentation']/text()")[0].strip() looking_for['ages'] = replace_chars(div.xpath(".//li[@id = 'ajax_ages']/text()")[0].strip()) looking_f...
Update looking_for attribute of a Profile.
def update_details(profile_tree, details): div = profile_tree.xpath("//div[@id = 'profile_details']")[0] for dl in div.iter('dl'): title = dl.find('dt').text item = dl.find('dd') if title == 'Last Online' and item.find('span') is not None: details[title.lower()] = item.f...
Update details attribute of a Profile.
def get_default_gentation(gender, orientation): gender = gender.lower()[0] orientation = orientation.lower() return gender_to_orientation_to_gentation[gender][orientation]
Return the default gentation for the given gender and orientation.
def replace_chars(astring): for k, v in CHAR_REPLACE.items(): astring = astring.replace(k, v) return astring
Replace certain unicode characters to avoid errors when trying to read various strings. Returns ---------- str
def add_newlines(tree): for br in tree.xpath("*//br"): br.tail = u"\n" + br.tail if br.tail else u"\n"
Add a newline character to the end of each <br> element.
def find_attractiveness(self, username, accuracy=1000, _lower=0, _higher=10000): average = (_higher + _lower)//2 if _higher - _lower <= accuracy: return average results = search(self._session, count=9, ...
:param username: The username to lookup attractiveness for. :param accuracy: The accuracy required to return a result. :param _lower: The lower bound of the search. :param _higher: The upper bound of the search.
def update_mailbox(self, mailbox_name='inbox'): with txn() as session: last_updated_name = '{0}_last_updated'.format(mailbox_name) okcupyd_user = session.query(model.OKCupydUser).join(model.User).filter( model.User.okc_id == self._user.profile.id ).wi...
Update the mailbox associated with the given mailbox name.
def photos(self): # Reverse because pictures appear in inverse chronological order. for photo_info in self.dest_user.profile.photo_infos: self.dest_user.photo.delete(photo_info) return [self.dest_user.photo.upload_and_confirm(info) for info in reversed(self.s...
Copy photos to the destination user.
def essays(self): for essay_name in self.dest_user.profile.essays.essay_names: setattr(self.dest_user.profile.essays, essay_name, getattr(self.source_profile.essays, essay_name))
Copy essays from the source profile to the destination profile.
def looking_for(self): looking_for = self.source_profile.looking_for return self.dest_user.profile.looking_for.update( gentation=looking_for.gentation, single=looking_for.single, near_me=looking_for.near_me, kinds=looking_for.kinds, ag...
Copy looking for attributes from the source profile to the destination profile.
def details(self): return self.dest_user.profile.details.convert_and_update( self.source_profile.details.as_dict )
Copy details from the source profile to the destination profile.
def SearchFetchable(session=None, **kwargs): session = session or Session.login() return util.Fetchable.fetch_marshall( SearchHTMLFetcher(session, **kwargs), util.SimpleProcessor( session, lambda match_card_div: Profile( session=session, ...
Search okcupid.com with the given parameters. Parameters are registered to this function through :meth:`~okcupyd.filter.Filters.register_filter_builder` of :data:`~okcupyd.html_search.search_filters`. :returns: A :class:`~okcupyd.util.fetchable.Fetchable` of :class:`~okcupyd.profile.Profile` ...
def refresh(self, reload=False): util.cached_property.bust_caches(self, excludes=('authcode')) self.questions = self.question_fetchable() if reload: return self.profile_tree
:param reload: Make the request to return a new profile tree. This will result in the caching of the profile_tree attribute. The new profile_tree will be returned.
def photo_infos(self): from . import photo pics_request = self._session.okc_get( u'profile/{0}/album/0'.format(self.username), ) pics_tree = html.fromstring(u'{0}{1}{2}'.format( u'<div>', pics_request.json()['fulls'], u'</div>' )) return [...
:returns: list of :class:`~okcupyd.photo.Info` instances for each photo displayed on okcupid.
def liked(self): if self.is_logged_in_user: return False classes = self._liked_xpb.one_(self.profile_tree).attrib['class'].split() return 'liked' in classes
:returns: Whether or not the logged in user liked this profile
def contacted(self): try: contacted_span = self._contacted_xpb.one_(self.profile_tree) except: return False else: timestamp = contacted_span.replace('Last contacted ', '') return helpers.parse_date_updated(timestamp)
:retuns: A boolean indicating whether the logged in user has contacted the owner of this profile.
def responds(self): contacted_text = self._contacted_xpb.\ get_text_(self.profile_tree).lower() if 'contacted' not in contacted_text: return contacted_text.strip().replace('replies ', '')
:returns: The frequency with which the user associated with this profile responds to messages.
def id(self): if self.is_logged_in_user: return self._current_user_id return int(self._id_xpb.one_(self.profile_tree))
:returns: The id that okcupid.com associates with this profile.
def age(self): if self.is_logged_in_user: # Retrieve the logged-in user's profile age return int(self._user_age_xpb.get_text_(self.profile_tree).strip()) else: # Retrieve a non logged-in user's profile age return int(self._age_xpb.get_text_(self....
:returns: The age of the user associated with this profile.
def match_percentage(self): return int(self._percentages_and_ratings_xpb. div.with_class('matchgraph--match'). div.with_class('matchgraph-graph'). canvas.select_attribute_('data-pct'). one_(self.profile_tree))
:returns: The match percentage of the logged in user and the user associated with this object.
def location(self): if self.is_logged_in_user: # Retrieve the logged-in user's profile location return self._user_location_xpb.get_text_(self.profile_tree) else: # Retrieve a non logged-in user's profile location return self._location_xpb.get_tex...
:returns: The location of the user associated with this profile.
def message(self, message, thread_id=None): return_value = helpers.Messager(self._session).send( self.username, message, self.authcode, thread_id ) self.refresh(reload=False) return return_value
Message the user associated with this profile. :param message: The message to send to this user. :param thread_id: The id of the thread to respond to, if any.
def rate(self, rating): parameters = { 'voterid': self._current_user_id, 'target_userid': self.id, 'type': 'vote', 'cf': 'profile2', 'target_objectid': 0, 'vote_type': 'personality', 'score': rating, } r...
Rate this profile as the user that was logged in with the session that this object was instantiated with. :param rating: The rating to give this user.
def find_question(self, question_id, question_fetchable=None): question_fetchable = question_fetchable or self.questions for question in question_fetchable: if int(question.id) == int(question_id): return question
:param question_id: The id of the question to search for :param question_fetchable: The question fetchable to iterate through if none is provided `self.questions` will be used.
def question_fetchable(self, **kwargs): return util.Fetchable(QuestionFetcher( self._session, self.username, is_user=self.is_logged_in_user, **kwargs ))
:returns: A :class:`~okcupyd.util.fetchable.Fetchable` instance that contains objects representing the answers that the user associated with this profile has given to okcupid.com match questions.
def authcode_get(self, path, **kwargs): kwargs.setdefault('params', {})['authcode'] = self.authcode return self._session.okc_get(path, **kwargs)
Perform an HTTP GET to okcupid.com using this profiles session where the authcode is automatically added as a query parameter.
def authcode_post(self, path, **kwargs): kwargs.setdefault('data', {})['authcode'] = self.authcode return self._session.okc_post(path, **kwargs)
Perform an HTTP POST to okcupid.com using this profiles session where the authcode is automatically added as a form item.
def arity_evaluation_checker(function): is_class = inspect.isclass(function) if is_class: function = function.__init__ function_info = inspect.getargspec(function) function_args = function_info.args if is_class: # This is to handle the fact that s...
Build an evaluation checker that will return True when it is guaranteed that all positional arguments have been accounted for.
def rerecord(ctx, rest): 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)
Rerecord tests.
def login( cls, username=None, password=None, requests_session=None, rate_limit=None ): requests_session = requests_session or requests.Session() session = cls(requests_session, rate_limit) # settings.USERNAME and settings.PASSWORD should not be made ...
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...
def getRoles(self): # 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, ...
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
def getRole(self, label): 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: f...
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`
def getMember(self, email, returned_properties=None): 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 g...
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 :...
def getItemType(self, title, returned_properties=None): 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 <I...
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...
def getAdministrator(self, email, returned_properties=None): 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("T...
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...
def queryWorkitems(self, query_str, projectarea_id=None, projectarea_name=None, returned_properties=None, archived=False): pa_id = (self.rtc_obj ._pre_get_resource(projectarea_id=projectarea_id, ...
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...
def getSavedQueriesByName(self, saved_query_name, projectarea_id=None, projectarea_name=None, creator=None): self.log.info("Start to fetch all saved queries with the name %s", saved_query_name) return self.getAllSavedQueries(projectarea_id=pr...
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. ...
def getMySavedQueries(self, projectarea_id=None, projectarea_name=None, saved_query_name=None): self.log.info("Start to fetch my saved queries") return self.getAllSavedQueries(projectarea_id=projectarea_id, projectarea_name=proje...
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...
def runSavedQueryByUrl(self, saved_query_url, returned_properties=None): 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() ...
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 ...
def runSavedQueryByID(self, saved_query_id, returned_properties=None): 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.Ba...
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...
def runSavedQuery(self, saved_query_obj, returned_properties=None): 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(er...
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...
def put(self, url, data=None, verify=False, headers=None, proxies=None, timeout=60, **kwargs): self.log.debug("Put a request to %s with data: %s", url, data) response = requests.put(url, data=data, verify=verify, headers=header...
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. ...
def validate_url(cls, url): if url is None: return None url = url.strip() while url.endswith('/'): url = url[:-1] return url
Strip and trailing slash to validate a url :param url: the url address :return: the valid url address :rtype: string
def _initialize(self): 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.__i...
Initialize the object from the request
def __initialize(self, resp): raw_data = xmltodict.parse(resp.content) root_key = list(raw_data.keys())[0] self.raw_data = raw_data.get(root_key) self.__initializeFromRaw()
Initialize from the response
def __initializeFromRaw(self): 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("-", "_") ...
Initialze from raw data (OrderedDict)
def relogin(self): self.log.info("Cookie expires. Relogin to get a new cookie.") self.headers = None self.headers = self._get_headers() self.log.debug("Successfully relogin.")
Relogin the RTC Server/Jazz when the token expires
def getProjectAreas(self, archived=False, returned_properties=None): return self._getProjectAreas(archived=archived, returned_properties=returned_properties)
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...
def getProjectArea(self, projectarea_name, archived=False, returned_properties=None): if not isinstance(projectarea_name, six.string_types) or not projectarea_name: excp_msg = "Please specify a valid ProjectArea name" self.log.er...
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:`...
def getProjectAreaByID(self, projectarea_id, archived=False, returned_properties=None): if not isinstance(projectarea_id, six.string_types) or not projectarea_id: excp_msg = "Please specify a valid ProjectArea ID" self.log.er...
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...
def getProjectAreaID(self, projectarea_name, archived=False): self.log.debug("Get the ProjectArea id by its name: %s", projectarea_name) proj_area = self.getProjectArea(projectarea_name, archived=archived) if proj_area: ...
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
def getProjectAreaIDs(self, projectarea_name=None, archived=False): projectarea_ids = list() if projectarea_name and isinstance(projectarea_name, six.string_types): projectarea_id = self.getProjectAreaID(projectarea_name, ...
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...
def checkProjectAreaID(self, projectarea_id, archived=False): self.log.debug("Check the validity of the ProjectArea id: %s", projectarea_id) proj_areas = self._getProjectAreas(archived=archived, projectarea_id=projectarea_id) ...
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
def getTeamArea(self, teamarea_name, projectarea_id=None, projectarea_name=None, archived=False, returned_properties=None): if not isinstance(teamarea_name, six.string_types) or not teamarea_name: excp_msg = "Please specify ...
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` ...
def getTeamAreas(self, projectarea_id=None, projectarea_name=None, archived=False, returned_properties=None): return self._getTeamAreas(projectarea_id=projectarea_id, projectarea_name=projectarea_name, archived=ar...
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. ...
def getPlannedFor(self, plannedfor_name, projectarea_id=None, projectarea_name=None, archived=False, returned_properties=None): if not isinstance(plannedfor_name, six.string_types) or not plannedfor_name: excp_msg = "Ple...
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...
def getPlannedFors(self, projectarea_id=None, projectarea_name=None, archived=False, returned_properties=None): return self._getPlannedFors(projectarea_id=projectarea_id, projectarea_name=projectarea_name, a...
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...
def getSeverity(self, severity_name, projectarea_id=None, projectarea_name=None): 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 spec...
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...
def getSeverities(self, projectarea_id=None, projectarea_name=None): return self._getSeverities(projectarea_id=projectarea_id, projectarea_name=projectarea_name)
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...
def getPriority(self, priority_name, projectarea_id=None, projectarea_name=None): 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 spec...
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...
def getPriorities(self, projectarea_id=None, projectarea_name=None): return self._getPriorities(projectarea_id=projectarea_id, projectarea_name=projectarea_name)
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...
def getFoundIn(self, foundin_name, projectarea_id=None, projectarea_name=None, archived=False): self.log.debug("Try to get <FoundIn %s>", foundin_name) if not isinstance(foundin_name, six.string_types) or not foundin_name: excp_msg = "Pl...
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 ...
def getFoundIns(self, projectarea_id=None, projectarea_name=None, archived=False): return self._getFoundIns(projectarea_id=projectarea_id, projectarea_name=projectarea_name, archived=archived)
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. ...
def getFiledAgainst(self, filedagainst_name, projectarea_id=None, projectarea_name=None, archived=False): self.log.debug("Try to get <FiledAgainst %s>", filedagainst_name) if not isinstance(filedagainst_name, six.string_types) or not filedagain...
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 ...
def getFiledAgainsts(self, projectarea_id=None, projectarea_name=None, archived=False): return self._getFiledAgainsts(projectarea_id=projectarea_id, projectarea_name=projectarea_name, archived=archived...
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` ...
def getTemplate(self, copied_from, template_name=None, template_folder=None, keep=False, encoding="UTF-8"): return self.templater.getTemplate(copied_from, template_name=template_name, template_folde...
Get template from some to-be-copied workitems More details, please refer to :class:`rtcclient.template.Templater.getTemplate`
def getTemplates(self, workitems, template_folder=None, template_names=None, keep=False, encoding="UTF-8"): self.templater.getTemplates(workitems, template_folder=template_folder, template_names=template_names...
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`
def listFieldsFromWorkitem(self, copied_from, keep=False): return self.templater.listFieldsFromWorkitem(copied_from, keep=keep)
List all the attributes to be rendered directly from some to-be-copied workitems More details, please refer to :class:`rtcclient.template.Templater.listFieldsFromWorkitem`
def getWorkitem(self, workitem_id, returned_properties=None): 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 isinstanc...
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 ...
def copyWorkitem(self, copied_from, title=None, description=None, prefix=None): copied_wi = self.getWorkitem(copied_from) if title is None: title = copied_wi.title if prefix is not None: title = prefix + title if description...
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 ...