當前位置: 首頁>>代碼示例>>Python>>正文


Python check.is_binary方法代碼示例

本文整理匯總了Python中binaryornot.check.is_binary方法的典型用法代碼示例。如果您正苦於以下問題:Python check.is_binary方法的具體用法?Python check.is_binary怎麽用?Python check.is_binary使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在binaryornot.check的用法示例。


在下文中一共展示了check.is_binary方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: check_substitutions

# 需要導入模塊: from binaryornot import check [as 別名]
# 或者: from binaryornot.check import is_binary [as 別名]
def check_substitutions(paths):
    """Method to check all paths have correct substitutions,
    used by other tests cases
    """
    # Assert that no match is found in any of the files

    PATTERN = '{{(\s?cookiecutter)[.](.*?)}}'
    RE_OBJ = re.compile(PATTERN)

    for path in paths:
        if is_binary(path):
            continue
        for line in open(path, 'r'):
            match = RE_OBJ.search(line)
            msg = 'cookiecutter variable not replaced in {}'
            assert match is None, msg.format(path) 
開發者ID:HackSoftware,項目名稱:cookiecutter-django-ansible,代碼行數:18,代碼來源:test_cookiecutter_generation.py

示例2: assert_variables_replaced

# 需要導入模塊: from binaryornot import check [as 別名]
# 或者: from binaryornot.check import is_binary [as 別名]
def assert_variables_replaced(paths):
    """Method to check that all paths have correct substitutions."""
    assert paths, 'No files are generated'

    for path in paths:
        if is_binary(path):
            continue

        with open(path, 'r') as template_file:
            file_contents = template_file.read()

        match = RE_OBJ.search(file_contents)
        msg = 'cookiecutter variable not replaced in {0} at {1}'

        # Assert that no match is found:
        assert match is None, msg.format(path, match.start()) 
開發者ID:wemake-services,項目名稱:wemake-django-template,代碼行數:18,代碼來源:test_project_generation.py

示例3: check_paths

# 需要導入模塊: from binaryornot import check [as 別名]
# 或者: from binaryornot.check import is_binary [as 別名]
def check_paths(paths):
    """
    Method to check all paths have correct substitutions,
    used by other tests cases
    """
    # Assert that no match is found in any of the files
    for path in paths:
        if is_binary(path):
            continue

        for line in open(path, "r"):
            match = RE_OBJ.search(line)
            msg = "cookiecutter variable not replaced in {}"
            assert match is None, msg.format(path) 
開發者ID:marcosschroh,項目名稱:cookiecutter-faust,代碼行數:16,代碼來源:test_cookiecutter_generation.py

示例4: check_password_replaced

# 需要導入模塊: from binaryornot import check [as 別名]
# 或者: from binaryornot.check import is_binary [as 別名]
def check_password_replaced(paths):
    PATTERN = 'POSTGRES_PASSWORD!!!'
    RE_OBJ = re.compile(PATTERN)

    for path in paths:
        if not is_binary(path):
            for line in open(path, 'r'):
                match = RE_OBJ.search(line)
                msg = 'password variable not replaced in {}'
                assert match is None, msg.format(path) 
開發者ID:HackSoftware,項目名稱:cookiecutter-django-ansible,代碼行數:12,代碼來源:test_cookiecutter_generation.py

示例5: log_output

# 需要導入模塊: from binaryornot import check [as 別名]
# 或者: from binaryornot.check import is_binary [as 別名]
def log_output(filename, source):
    """Log output to the database.

    Called by patched functions that do some sort of output (writing to a file
    etc) with the filename and some sort of information about the source.

    Note: the source parameter is currently not stored in the database.
    """
    if isinstance(filename, list):
        for f in filename:
            log_output(f, source)
        return
    elif not isinstance(filename, six.string_types):
        try:
            filename = filename.name
        except:
            pass
    filename = os.path.abspath(filename)

    version = get_version(source)
    db = open_or_create_db()

    if option_set('data', 'file_diff_outputs') and os.path.isfile(filename) \
       and not is_binary(filename):
        tf = tempfile.NamedTemporaryFile(delete=False)
        shutil.copy2(filename, tf.name)
        add_file_diff_to_db(filename, tf.name, db)

    if option_set('general', 'debug'):
        print("Output to %s using %s" % (filename, source))
    #Update object in DB
    # data hash will be hashed at script exit, if enabled
    db.update(append("outputs", filename, no_duplicates=True), eids=[RUN_ID])
    db.update(append("libraries", version, no_duplicates=True), eids=[RUN_ID])
    db.close() 
開發者ID:recipy,項目名稱:recipy,代碼行數:37,代碼來源:log.py

示例6: check_paths

# 需要導入模塊: from binaryornot import check [as 別名]
# 或者: from binaryornot.check import is_binary [as 別名]
def check_paths(paths):
    """Method to check all paths have correct substitutions,
    used by other tests cases
    """
    # Assert that no match is found in any of the files
    for path in paths:
        if is_binary(path):
            continue
        for line in open(path, 'r'):
            match = RE_OBJ.search(line)
            msg = 'cookiecutter variable not replaced in {}'
            assert match is None, msg.format(path) 
開發者ID:chrisdev,項目名稱:wagtail-cookiecutter-foundation,代碼行數:14,代碼來源:test_cookiecutter_generation.py

示例7: convert_win_2_linux

# 需要導入模塊: from binaryornot import check [as 別名]
# 或者: from binaryornot.check import is_binary [as 別名]
def convert_win_2_linux(filename):
    if not is_binary(filename):
        file_content = open(filename, mode='r', encoding='utf-8-sig').read()
        return file_content.replace("\n\r", "\n").encode('utf-8')

    return open(filename, mode='rb').read() 
開發者ID:KatharaFramework,項目名稱:Kathara,代碼行數:8,代碼來源:utils.py


注:本文中的binaryornot.check.is_binary方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。