예제 #1
0
파일: test_config.py 프로젝트: Phyks/BMC
 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())
예제 #2
0
파일: test_config.py 프로젝트: m000/BMC
 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())
예제 #3
0
파일: test_config.py 프로젝트: m000/BMC
 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())
예제 #4
0
파일: test_config.py 프로젝트: Phyks/BMC
 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())
예제 #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
예제 #6
0
파일: bmc.py 프로젝트: drvinceknight/BMC
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':
예제 #7
0
파일: test_config.py 프로젝트: Phyks/BMC
 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"))
예제 #8
0
파일: test_config.py 프로젝트: Phyks/BMC
 def test_set(self):
     config = Config(base_config_path=self.folder)
     config.set("foo", "bar")
     self.assertEqual(config.get("foo"), "bar")
예제 #9
0
파일: test_config.py 프로젝트: Phyks/BMC
 def test_get(self):
     config = Config(base_config_path=self.folder)
     self.assertEqual(config.get("proxies"), [''])
예제 #10
0
파일: test_config.py 프로젝트: Phyks/BMC
 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)
예제 #11
0
파일: test_config.py 프로젝트: m000/BMC
 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"))
예제 #12
0
파일: test_config.py 프로젝트: m000/BMC
 def test_set(self):
     config = Config(base_config_path=self.folder)
     config.set("foo", "bar")
     self.assertEqual(config.get("foo"), "bar")
예제 #13
0
파일: test_config.py 프로젝트: m000/BMC
 def test_get(self):
     config = Config(base_config_path=self.folder)
     self.assertEqual(config.get("proxies"), [''])
예제 #14
0
파일: test_config.py 프로젝트: m000/BMC
 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)