Skip to content

Commit

Permalink
PEP8
Browse files Browse the repository at this point in the history
  • Loading branch information
Cabalist committed Feb 5, 2019
1 parent b9cebcf commit 7eaceb2
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,18 @@ Copy this file to .git/hooks/
"""

import os
import sys
import string
import re

import string
import sys
from subprocess import call, check_output

try:
from urllib.parse import urlparse
except ImportError:
from urlparse import urlparse

from fileinput import FileInput

# https://github.com/python/cpython/commit/6cb7b659#diff-78790b53ff259619377058acd4f74672
if sys.version_info[0] < 3:
class FileInputCtx(FileInput):
Expand All @@ -35,6 +36,7 @@ if sys.version_info[0] < 3:
def __exit__(self, type, value, traceback):
self.close()


FileInput = FileInputCtx


Expand Down Expand Up @@ -91,15 +93,15 @@ def espurna_get_version(base, version_h="code/espurna/config/version.h"):

TEMPLATES = {
"![travis]": "[![travis](https://travis-ci.org/{USER}/{REPO}.svg?branch={BRANCH})]"
"(https://travis-ci.org/{USER}/{REPO})\n",
"![version]": "[![version](https://img.shields.io/badge/version-{VERSION:escape_hyphen}-brightgreen.svg)](CHANGELOG.md)\n",
"(https://travis-ci.org/{USER}/{REPO})\n",
"![version]": "[![version](https://img.shields.io/badge/version-{VERSION:escape_hyphen}-brightgreen.svg)]"
"(CHANGELOG.md)\n",
"![branch]": "[![branch](https://img.shields.io/badge/branch-{BRANCH:escape_hyphen}-orange.svg)]"
"(https://github.com/{USER}/{REPO}/tree/{BRANCH}/)\n",
"(https://github.com/{USER}/{REPO}/tree/{BRANCH}/)\n",
}

README = "README.md"


if __name__ == "__main__":
base = os.getcwd()

Expand All @@ -117,13 +119,15 @@ if __name__ == "__main__":
for k, tmpl in TEMPLATES.items()
]


def fmt_line(line):
for match, tmpl in templates:
if match in line:
return tmpl

return line


path = os.path.join(base, README)

with FileInput(path, inplace=True) as readme:
Expand Down

0 comments on commit 7eaceb2

Please sign in to comment.