예제 #1
0
 def test_blob_file_handle(self):
     with tempfile.TemporaryDirectory() as tmp:
         with utils.ChangeDir(tmp):
             self._setup_git()
             with git.blob_file_handle('ba0e162e1c47469e3fe4b393a8bf8c569f302116') as f:
                 self.assertType( f, io.BufferedReader)
                 content = f.readlines()
                 self.assertEqual(content, [b'bar'])
예제 #2
0
파일: test_git.py 프로젝트: ltgrant/opt
 def test_blob_file_handle(self):
     with tempfile.TemporaryDirectory() as tmp:
         with utils.ChangeDir(tmp):
             self._setup_git()
             with git.blob_file_handle(
                     'ba0e162e1c47469e3fe4b393a8bf8c569f302116') as f:
                 self.assertType(f, io.BufferedReader)
                 content = f.readlines()
                 self.assertEqual(content, [b'bar'])
예제 #3
0
파일: common.py 프로젝트: ltgrant/opt
def process(obj_id, target, xslt = None):
  """ get file from git, process, write to target folder

  Arguments:
  obj_id -- git object id of the file (as string)
  target -- target folder path (as string, with trailing slash)
  xslt   -- xslt file path if xml-stylesheet PI should be included,
            no PI will be included if null (which is default)
  """
  stream = io.TextIOWrapper(git.blob_file_handle(obj_id), encoding='utf8')
  r = parseFile(stream)
  dump(target, r, xslt)
예제 #4
0
def process( obj_id, target):
    """ get file from git, process, write to target folder

    Arguments:
    obj_id -- git object id of the file (as string)
    target -- target folder path (as string, with trailing slash)
    """
    stream = io.TextIOWrapper( git.blob_file_handle(obj_id), encoding='utf8')
    r = parseFile(stream)
    rec = serializeRecipes(r)
    rec.addprevious(etree.ProcessingInstruction('xml-stylesheet', 'type="text/xsl" href="' + settings.XSLT + '"'))
    et = etree.ElementTree(rec)
    et.write(target,xml_declaration=True,pretty_print=True,encoding='UTF-8')