Ejemplo n.º 1
0
def test_paper_metadata(volume, prefix):
    for soup, info in paper_iterator(volume, prefix):
        citation_title = soup.find_all(attrs={"name": "citation_title"})
        assert len(citation_title) == 1
        if "title_html" in info.keys():
            citation_title[0]["content"] == info["title_html"]
        else:
            assert citation_title[0]["content"] == utils.xml_string(
                info["title"])

        citation_journal = soup.find_all(
            attrs={"name": "citation_journal_title"})
        assert len(citation_journal) == 1
        assert citation_journal[0][
            "content"] == "Journal of Machine Learning Research"

        citation_issn = soup.find_all(attrs={"name": "citation_issn"})
        assert len(citation_issn) == 1
        assert citation_issn[0]["content"] == "1533-7928"

        citation_authors = soup.find_all(attrs={"name": "citation_author"})
        citation_authors = set([c["content"] for c in citation_authors])
        set_authors = set([utils.xml_string(c) for c in info["authors"]])

        assert citation_authors == set_authors
Ejemplo n.º 2
0
 def set_remote_office(self, **kwargs):
     """Set remote office call setting to given state.
     """
     assert all([x in kwargs for x in ("active", "number")])
     tree = _update_forward_number(self.xsi_get("services/remoteoffice"),
                                   "remoteOfficeNumber", kwargs)
     self.xsi_put("services/remoteoffice", utils.xml_string(tree))
Ejemplo n.º 3
0
 def _set_active_state(self, api_endpoint, **kwargs):
     assert "enabled" in kwargs
     enabled = kwargs["enabled"]
     tree = self.xsi_get(api_endpoint)
     tree.xpath("//*[local-name() = 'active']")[0].text = \
         utils.bool_to_str(enabled)
     self.xsi_put(api_endpoint, utils.xml_string(tree))
Ejemplo n.º 4
0
 def set_simultaneous_ring(self, **kwargs):
     """Set given call forward type to given state.
     """
     tree = _update_simultaneous_ring(
         self.xsi_get("services/simultaneousringpersonal"), kwargs)
     self.xsi_put("services/simultaneousringpersonal",
                  utils.xml_string(tree))
Ejemplo n.º 5
0
def deploy_dm_changes(user):
    """Creates/updates dm_config.xml file on the remote runner

    The file is created from the dm_config tree for user's account.
    You can use \`Set dm config value\` to manipulate this tree before
    deploying the changes.

    Sets the dm-url to point to the local file dm_config.xml
    """

    c, a = utils.client_for_user(user), utils.account_for_user(user)
    utils.put_app_file(c,
                       "dm_config.xml",
                       utils.xml_string(a["dm_config"]))
    #logger.debug("Deploy DM Config for user %s. Config:\n%s" %
    #             (user, utils.xml_string(a["dm_config"])))

    client = utils.client_for_user(user)
    app_dir = utils.get_remote_appdir(client)
    if utils.on_windows():
        items = app_dir.split("\\")
        new_app_dir = ""
        for item in items:
            new_app_dir += item + "/"
        app_dir = new_app_dir
    app_file = app_dir + "/" + "dm_config.xml"
    c["dm-url"] = app_file
    if utils.on_ucaas():
        set_app_ini_value(user, "testing/dm_config_file_override",
                          c["dm-url"])
        deploy_app_ini_changes(user)
Ejemplo n.º 6
0
def process(info, prefix, env):
    vol = info['volume']
    id = info['id']
    if 'title_html' not in info:
        info['title_html'] = info['title']

    if 'authors_html' not in info:
        info['authors_html'] = [utils.xml_string(a) for a in info['authors']]

    if 'title_bibtex' not in info:
        info['title_bibtex'] = info['title']


    with open('output' + prefix + 'papers/v%s/%s.html' % (vol, id), 'w') as f:

        editorial_board_template = env.get_template('papers/item.html')
        out = editorial_board_template.render(**info, prefix=prefix)
        f.write(out)
    with open('output' + prefix + 'papers/v%s/%s.bib' % (vol, id), 'w') as f:
        editorial_board_template = env.get_template('papers/biblio.bib')
        out = editorial_board_template.render(**info, prefix=prefix)
        f.write(out)
    papers_dir = 'output' + prefix + 'papers/'
    os.makedirs('output' + prefix + 'papers/volume%s/%s' % (vol, id), exist_ok=True)
    shutil.copy(
        'v%s/%s/%s.pdf' % (vol, id, id),
        'output' + prefix + 'papers/volume%s/%s/%s.pdf' % (vol, id, id))
Ejemplo n.º 7
0
 def set_dnd(self, **kwargs):
     assert "enabled" in kwargs
     enabled = kwargs["enabled"]
     tree = self.xsi_get("services/donotdisturb")
     tree.xpath("//*[local-name() = 'active']")[0].text = \
         utils.bool_to_str(enabled)
     if "ringSplash" in kwargs:
         tree.xpath("//*[local-name() = 'ringSplash']")[0].text = \
             utils.bool_to_str(kwargs["ringSplash"])
     self.xsi_put("services/donotdisturb", utils.xml_string(tree))
Ejemplo n.º 8
0
def get_info(vol):
    os.chdir('v%s' % vol)
    ids = glob.glob('??-???')
    info_list = []
    for id in ids:
        with open('%s/info.json' % id, 'r') as fp:
            # some cleanup for the html display
            id_info = json.load(fp)
            id_info['title'] = utils.xml_string(id_info['title'])
            # some authors write {TeXt} to ensure that its capitalized correctly in latex
            id_info['title'].replace('{', '').replace('}', '')

            id_info['authors_string'] = utils.xml_string(', '.join(id_info['authors']))
            id_info['abstract'] = utils.xml_string(id_info['abstract'])
            id_info['authors_bibtex'] = ' and '.join(id_info['authors'])
        info_list.append(id_info)
    os.chdir('..')
    # sort by issue
    return sorted(info_list, key=lambda k: k['issue'])
Ejemplo n.º 9
0
 def set_call_forwarding(self, **kwargs):
     """Set given call forward type to given state.
     """
     assert all([x in kwargs for x in ("active", "number")])
     forward_type = kwargs.get("forward_type", "always")
     assert forward_type in ("always", "busy", "noanswer", "notreachable")
     tree = _update_forward_number(
         self.xsi_get("services/callforwarding%s" % forward_type),
         "forwardToPhoneNumber", kwargs)
     self.xsi_put("services/callforwarding%s" % forward_type,
                  utils.xml_string(tree))
Ejemplo n.º 10
0
def cache_account_server_data(fname):
    "Write account data to given .json file"
    data = copy.deepcopy(ACCOUNTS)
    for a, val in data.iteritems():
        for k in ["dm_config",
                  "xmpp_roster",
                  "localstore_contacts",
                  "own_vcard"]:
            if k in val and type(val[k]) != str:
                val[k] = utils.xml_string(val[k])
    open(fname, "w").write(json.dumps(data, indent=2))
    return data
Ejemplo n.º 11
0
 def _session_start(self, event):
     contacts_store = cElementTree.fromstring(
         utils.xml_string(self.contact_storage_xml))
     pubsub = cElementTree.fromstring(
         "<last-update>%s</last-update>" % self.timestamp)
     timestamp = cElementTree.fromstring(
         "<timestamp xmlns='bsft-private-storage'>%s</timestamp>" %
         self.timestamp)
     self['xep_0049'].store(timestamp, block=True)
     self['xep_0049'].store(contacts_store[0], block=True)
     node = "contact-storage-update-%s" % self.jid.replace("@", "-")
     item = "contact-storage-date-item-%s" % self.jid.replace("@", "-")
     self['xep_0060'].publish("pubsub.broadsoft.com",
                              node, item, pubsub)
     self.disconnect()
Ejemplo n.º 12
0
 def remove_broadworks_anywhere(self):
     """Set Click-To-Dial flag to False and delete all locations.
     """
     tree = copy.deepcopy(self.xsi_get("services/broadworksanywhere"))
     e = tree.find(utils.ns_escape("locations"))
     if e is not None:
         for phone in tree.findall(
                 utils.ns_escape("locations/location"
                                 "/phoneNumber")):
             self.delete_broadworks_anywhere_location(phone.text)
         # Remove locations to be able to set click-to-dial flag to false.
         # Xsi PUT requirement "phoneNumber element must include the
         # country code element."
         e.getparent().remove(e)
     tree.xpath("//*[local-name() = 'alertAllLocationsForClickToDialCalls']"
                )[0].text = 'false'
     self.xsi_put("services/broadworksanywhere", utils.xml_string(tree))
Ejemplo n.º 13
0
def test_paper_title(volume, prefix='/beta/'):
    for soup, info in paper_iterator(volume, prefix):
        assert soup.title.string == utils.xml_string(info['title'])
Ejemplo n.º 14
0
def test_xml_string():
    t = r"\mathcal{O}"
    assert utils.xml_string(t) == t
Ejemplo n.º 15
0
def test_paper_title(volume, prefix="/beta/"):
    for soup, info in paper_iterator(volume, prefix):
        if "title_html" in info.keys():
            assert soup.title.string == info["title_html"]
        else:
            assert soup.title.string == utils.xml_string(info["title"])
Ejemplo n.º 16
0
def test_xmlstring():
    assert utils.xml_string("Tak{{\\'a}}{\\v{c}}") == "Takáč"
    assert (utils.xml_string(
        "Mar{{\\'i}}a del Carmen Rodr{{\\'i}}guez-Hern{{\\'a}}ndez") ==
            "María del Carmen Rodríguez-Hernández")
Ejemplo n.º 17
0
 def _set_element_value(self, api_endpoint, element_name, element_value):
     tree = self.xsi_get(api_endpoint)
     tree.xpath("//*[local-name() = '%s']" % element_name)[0].text = \
         element_value
     self.xsi_put(api_endpoint, utils.xml_string(tree))