Example #1
0
def main():
    args = parse_arguments()

    if args.getmousepos:
        utils.getjoinposn()
    elif args.updatepass is not None:
        utils.update_pass(args.updatepass)
    elif args.append is not None:
        utils.append(args.append)
    elif args.changepass is not None:
        utils.change_pass(args.changepass)
    else:
        config = configparser.ConfigParser()
        config.read("data.ini")
        joinposn = config["VALUES"]["join"].split(", ")
        try:
            joinposn = [int(x) for x in joinposn]
        except ValueError:
            # fmt: off
            print("Oops, it looks like you haven't"
                  "set the positon of join button.")
            # fmt: on

        subject = utils.get_subject() if args.subject is None else args.subject
        zoom_id, zoom_pass = utils.get_credentials(subject)
        utils.auto_type(zoom_id, zoom_pass, joinposn)
Example #2
0
    def get_preference(self, pref_name):
        """ Gets a single named preference

        @returns the value, typed to str/bool/int/float regarding its content.
        """
        resp = self.request_single('GetPrefs', {'pref': {'name': pref_name}})
        return utils.auto_type(resp['_content'])
Example #3
0
    def get_preference(self, pref_name):
        """ Gets a single named preference

        :returns: the value, typed to str/bool/int/float regarding its content.
        """
        resp = self.request_single('GetPrefs', {'pref': {'name': pref_name}})
        return utils.auto_type(resp['_content'])
Example #4
0
    def _parse_a_tags(cls, dic):
        """ Iterates over all <a> tags and builds a dict with those.
        If a tag with same "n" attributes appears several times, the
        dict value is a list with the tags values, else it's a string.

        :param: dic the dict describing the tag
        :returns:   a dict
        """
        props = {}

        if dic.has_key('a'):
            if len(dic['a']) == 2 and isinstance(
                    dic['a'],
                    dict):  # transform to list if there is only one attribute
                childs = [dic['a']]
            else:
                childs = dic['a']
        else:
            childs = []

        for child in childs:
            k = child[cls.ATTRNAME_PROPERTY]
            try:
                v = child['_content']
            except KeyError:
                v = None

            try:
                v = utils.auto_type(str(v))
            except UnicodeEncodeError:
                # Some times, str() fails because of accents...
                v = utils.auto_type(unicode(v))

            if props.has_key(k):
                prev_v = props[k]
                if type(prev_v) != list:
                    props[k] = [
                        prev_v,
                    ]

                props[k].append(v)

            else:
                props[k] = v
        return props
Example #5
0
    def _unparse_a_tags(cls, attrs_dict):
        """ Iterates over the dictionary

        @param attrs_dict a dict of attributes
        @returns   a SimpleXMLElement list containing <a> tags
        """
        prop_tags = []

        for k, v in attrs_dict.items():
            node = {cls.ATTRNAME_PROPERTY: k, '_content': utils.auto_type(v)}
            prop_tags.append(node)

        return prop_tags
Example #6
0
    def _unparse_a_tags(cls, attrs_dict):
        """ Iterates over the dictionary

        :param: attrs_dict a dict of attributes
        :returns:   a SimpleXMLElement list containing <a> tags
        """
        prop_tags = []

        for k, v in attrs_dict.items():
            node = {cls.ATTRNAME_PROPERTY: k, '_content': utils.auto_type(v)}
            prop_tags.append(node)

        return prop_tags
Example #7
0
    def get_preferences(self):
        """ Gets all the preferences of the current user

        @returns a dict presenting the preferences by name, values are
                 typed to str/bool/int/float regarding their content.
        """
        pref_list = self.request('GetPrefs')['pref']

        out = {}
        for pref in pref_list:
            out[pref['name']] = utils.auto_type(pref['_content'])

        return out
Example #8
0
    def get_preferences(self):
        """ Gets all the preferences of the current user

        :returns: a dict presenting the preferences by name, values are
                 typed to str/bool/int/float regarding their content.
        """
        pref_list = self.request('GetPrefs')['pref']

        out = {}
        for pref in pref_list:
            out[pref['name']] = utils.auto_type(pref['_content'])

        return out
Example #9
0
    def _parse_a_tags(cls, dic):
        """ Iterates over all <a> tags and builds a dict with those.
        If a tag with same "n" attributes appears several times, the
        dict value is a list with the tags values, else it's a string.

        :param: dic the dict describing the tag
        :returns:   a dict
        """
        props = {}

        if dic.has_key('a'):
            childs = dic['a']
        else:
            childs = []

        for child in childs:
            k = child[cls.ATTRNAME_PROPERTY]
            try:
                v = child['_content']
            except KeyError:
                v = None

            try:
                v = utils.auto_type(str(v))
            except UnicodeEncodeError:
                # Some times, str() fails because of accents...
                v = utils.auto_type(unicode(v))

            if props.has_key(k):
                prev_v = props[k]
                if type(prev_v) != list:
                    props[k] = [prev_v,]

                props[k].append(v)

            else:
                props[k] = v
        return props
Example #10
0
 def __setitem__(self, k, v):
     self._a_tags[k] = utils.auto_type(v)
Example #11
0
 def __setitem__(self, k, v):
     self._a_tags[k] = utils.auto_type(v)