Exemplo n.º 1
0
 def test_load_with_file(self):
     config = self.default_config
     config["foo"] = "bar"
     with open(self.folder+"bmc.json", 'w') as fh:
         json.dump(config, fh)
     config_read = Config(base_config_path=self.folder)
     self.assertEqual(config, config_read.as_dict())
Exemplo n.º 2
0
 def test_load_with_file(self):
     config = self.default_config
     config["foo"] = "bar"
     with open(self.folder + "bmc.json", 'w') as fh:
         json.dump(config, fh)
     config_read = Config(base_config_path=self.folder)
     self.assertEqual(config, config_read.as_dict())
Exemplo n.º 3
0
 def test_save(self):
     config = Config(base_config_path=self.folder)
     config.set("foo", "bar")
     config.save()
     with open(self.folder + "bmc.json", 'r') as fh:
         read = json.loads(fh.read())
     self.assertEqual(read, config.as_dict())
Exemplo n.º 4
0
 def test_save(self):
     config = Config(base_config_path=self.folder)
     config.set("foo", "bar")
     config.save()
     with open(self.folder+"bmc.json", 'r') as fh:
         read = json.loads(fh.read())
     self.assertEqual(read, config.as_dict())
Exemplo n.º 5
0
import argparse
import os
import shutil
import subprocess
import sys
import tempfile
import bibtexparser
from codecs import open
from libbmc.config import Config
from libbmc import backend
from libbmc import fetcher
from libbmc import tearpages
from libbmc import tools

config = Config()
EDITOR = os.environ.get('EDITOR') if os.environ.get('EDITOR') else 'vim'


def checkBibtex(filename, bibtex_string):
    print("The bibtex entry found for " + filename + " is:")

    bibtex = bibtexparser.loads(bibtex_string)
    bibtex = bibtex.entries_dict
    try:
        bibtex = bibtex[list(bibtex.keys())[0]]
        # Check entries are correct
        if "title" not in bibtex:
            raise AssertionError
        if "authors" not in bibtex and "author" not in bibtex:
            raise AssertionError
Exemplo n.º 6
0
import argparse
import os
import shutil
import subprocess
import sys
import tempfile
from bibtexparser.bparser import BibTexParser
from codecs import open
from libbmc.config import Config
from libbmc import backend
from libbmc import fetcher
from libbmc import tearpages
from libbmc import tools


config = Config()
EDITOR = os.environ.get('EDITOR') if os.environ.get('EDITOR') else 'vim'


def checkBibtex(filename, bibtex_string):
    print("The bibtex entry found for "+filename+" is:")

    bibtex = BibTexParser(bibtex_string)
    bibtex = bibtex.get_entry_dict()
    try:
        bibtex = bibtex[list(bibtex.keys())[0]]
        # Check entries are correct
        assert bibtex['title']
        if bibtex['type'] == 'article':
            assert bibtex['authors']
        elif bibtex['type'] == 'book':
Exemplo n.º 7
0
 def test_masks(self):
     with open(self.folder+"masks.py", 'w') as fh:
         fh.write("def f(x): return x")
     config = Config(base_config_path=self.folder)
     self.assertEqual("foo", config.get("format_custom")[0]("foo"))
Exemplo n.º 8
0
 def test_set(self):
     config = Config(base_config_path=self.folder)
     config.set("foo", "bar")
     self.assertEqual(config.get("foo"), "bar")
Exemplo n.º 9
0
 def test_get(self):
     config = Config(base_config_path=self.folder)
     self.assertEqual(config.get("proxies"), [''])
Exemplo n.º 10
0
 def test_load_without_file(self):
     config = Config(base_config_path=self.folder)
     self.assertEqual(config.as_dict(), self.default_config)
     with open(self.folder+"bmc.json", 'r') as fh:
         read = json.loads(fh.read())
     self.assertEqual(read, self.default_config)
Exemplo n.º 11
0
 def test_masks(self):
     with open(self.folder + "masks.py", 'w') as fh:
         fh.write("def f(x): return x")
     config = Config(base_config_path=self.folder)
     self.assertEqual("foo", config.get("format_custom")[0]("foo"))
Exemplo n.º 12
0
 def test_set(self):
     config = Config(base_config_path=self.folder)
     config.set("foo", "bar")
     self.assertEqual(config.get("foo"), "bar")
Exemplo n.º 13
0
 def test_get(self):
     config = Config(base_config_path=self.folder)
     self.assertEqual(config.get("proxies"), [''])
Exemplo n.º 14
0
 def test_load_without_file(self):
     config = Config(base_config_path=self.folder)
     self.assertEqual(config.as_dict(), self.default_config)
     with open(self.folder + "bmc.json", 'r') as fh:
         read = json.loads(fh.read())
     self.assertEqual(read, self.default_config)