示例#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)