Make the yaml check work on older pythons + pylint cleanups

This commit is contained in:
Joshua Harlow 2012-09-14 19:19:01 -07:00
parent acc9f26e43
commit 7d95a7a055
6 changed files with 13 additions and 22 deletions

View File

@ -149,12 +149,12 @@ def ensure_anvil_dir():
sh.chown_r(ANVIL_DIR, uid, gid)
def store_current_settings(settings):
def store_current_settings(c_settings):
try:
# Remove certain keys that just shouldn't be saved
to_save = dict(settings)
to_save = dict(c_settings)
for k in ['action', 'verbose', 'dryrun']:
if k in settings:
if k in c_settings:
to_save.pop(k, None)
with sh.Rooted(True):
with open(SETTINGS_FN, 'w') as fh:

View File

@ -15,7 +15,6 @@
# under the License..
import abc
import os
from anvil import cfg
from anvil import colorizer

View File

@ -87,7 +87,7 @@ class Unpacker(object):
return files
def _pat_checker(self, fn, patterns):
(root_fn, fn_ext) = os.path.splitext(fn)
(_root_fn, fn_ext) = os.path.splitext(fn)
if utils.has_any(fn_ext.lower(), *BAD_EXTENSIONS):
return False
for pat in patterns:

View File

@ -37,28 +37,22 @@ PER_CALL_AM = 50
class GitChangeLog(object):
__meta__ = abc.ABCMeta
def __init__(self, wkdir, max_history=-1):
def __init__(self, wkdir):
self.wkdir = wkdir
self.max_history = max_history
self.date_buckets = None
self.mail_mapping = None
def _parse_mailmap(self):
if self.mail_mapping is not None:
return self.mail_mapping
mapping = {}
mailmap_fn = sh.joinpths(self.wkdir, '.mailmap')
for line in sh.load_file(mailmap_fn).splitlines():
line = line.strip()
if not line.startswith('#') and ' ' in line:
try:
canonical_email, alias = [x for x in line.split(' ')
if x.startswith('<')]
(canonical_email, alias) = [x for x in line.split(' ') if x.startswith('<')]
mapping[alias] = canonical_email
except (TypeError, ValueError, IndexError):
pass
self.mail_mapping = mapping
return self.mail_mapping
return mapping
def _get_commit_detail(self, commit, field, am=1):
detail_cmd = ['git', 'log', '--color=never', '-%s' % (am), "--pretty=format:%s" % (field), commit]
@ -84,17 +78,15 @@ class GitChangeLog(object):
if summary.startswith('merge commit'):
return True
if summary.startswith("merge branch"):
return True
return True
if summary.startswith("merge remote"):
return True
return True
if not all([summary, date, email, name]):
return True
return False
def _get_log(self):
log_cmd = ['git', 'log', '--pretty=oneline', '--color=never']
if self.max_history > 0:
log_cmd += ['-n%s' % (self.max_history)]
(sysout, _stderr) = sh.execute(*log_cmd, cwd=self.wkdir)
lines = sysout.strip('\n').splitlines()

View File

@ -24,8 +24,6 @@ from keyring.backend import UncryptedFileKeyring
from keyring.util import properties
from anvil import log as logging
from anvil import shell as sh
from anvil import utils
LOG = logging.getLogger(__name__)
RAND_PW_LEN = 20

View File

@ -7,6 +7,8 @@ import sys
import yaml
if __name__ == "__main__":
with open(sys.argv[1], 'r') as f:
yaml.load(f)
fh = open(sys.argv[1], 'r')
yaml.load(fh.read())
fh.close()