From d23a83060ddad0b6da5504d8cb5d524891ad9631 Mon Sep 17 00:00:00 2001 From: Daniel Narvaez Date: Wed, 26 Dec 2012 11:25:03 +0000 Subject: pep8ize --- (limited to 'devbot/state.py') diff --git a/devbot/state.py b/devbot/state.py index 7c2a839..41d458b 100644 --- a/devbot/state.py +++ b/devbot/state.py @@ -9,9 +9,11 @@ _BUILT_MODULES = "builtmodules" _FULL_BUILD = "fullbuild" _SYSTEM_CHECK = "syscheck" + def _get_state_path(name): return os.path.join(config.build_state_dir, "%s.json" % name) + def _load_state(name, default=None): state = default @@ -23,11 +25,13 @@ def _load_state(name, default=None): return state + def _save_state(name, state): with open(_get_state_path(name), "w+") as f: json.dump(state, f, indent=4) f.write('\n') + def _get_diff_hash(git_module): diff = git_module.diff().strip() if diff: @@ -35,6 +39,7 @@ def _get_diff_hash(git_module): else: return None + def _get_root_commit_id(): git_module = git.get_root_module() if git_module: @@ -44,6 +49,7 @@ def _get_root_commit_id(): return commit_id + def built_module_touch(module): git_module = module.get_git_module() built_modules = _load_state(_BUILT_MODULES, {}) @@ -54,6 +60,7 @@ def built_module_touch(module): _save_state(_BUILT_MODULES, built_modules) + def built_module_is_unchanged(module): git_module = module.get_git_module() built_modules = _load_state(_BUILT_MODULES, {}) @@ -65,6 +72,7 @@ def built_module_is_unchanged(module): return info["diff_hash"] == _get_diff_hash(git_module) and \ info["commit"] == git_module.get_commit_id() + def system_check_is_unchanged(): system_check = _load_state(_SYSTEM_CHECK) if not system_check: @@ -72,11 +80,13 @@ def system_check_is_unchanged(): return system_check["commit"] == _get_root_commit_id() + def system_check_touch(): system_check = _load_state(_SYSTEM_CHECK, {}) system_check["commit"] = _get_root_commit_id() _save_state(_SYSTEM_CHECK, system_check) + def full_build_is_required(): full_build = _load_state(_FULL_BUILD) if not full_build: @@ -84,11 +94,13 @@ def full_build_is_required(): return not (full_build["last"] == config.get_full_build()) + def full_build_touch(): full_build = _load_state(_FULL_BUILD, {}) full_build["last"] = config.get_full_build() _save_state(_FULL_BUILD, full_build) + def clean_build_state(): try: for name in _BUILT_MODULES, _FULL_BUILD: @@ -96,6 +108,7 @@ def clean_build_state(): except OSError: pass + def clean(): _state = None -- cgit v0.9.1