Return-Path: X-Original-To: apmail-cordova-dev-archive@www.apache.org Delivered-To: apmail-cordova-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A020517A33 for ; Fri, 13 Mar 2015 18:16:31 +0000 (UTC) Received: (qmail 78478 invoked by uid 500); 13 Mar 2015 18:16:31 -0000 Delivered-To: apmail-cordova-dev-archive@cordova.apache.org Received: (qmail 78437 invoked by uid 500); 13 Mar 2015 18:16:31 -0000 Mailing-List: contact dev-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cordova.apache.org Delivered-To: mailing list dev@cordova.apache.org Received: (qmail 78426 invoked by uid 99); 13 Mar 2015 18:16:31 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 13 Mar 2015 18:16:31 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id B4048E17BF; Fri, 13 Mar 2015 18:16:30 +0000 (UTC) From: dblotsky To: dev@cordova.apache.org Reply-To: dev@cordova.apache.org References: In-Reply-To: Subject: [GitHub] cordova-medic pull request: Medic Refactor Content-Type: text/plain Message-Id: <20150313181630.B4048E17BF@git1-us-west.apache.org> Date: Fri, 13 Mar 2015 18:16:30 +0000 (UTC) Github user dblotsky commented on a diff in the pull request: https://github.com/apache/cordova-medic/pull/37#discussion_r26409868 --- Diff: buildbot-conf/cordova.conf --- @@ -0,0 +1,336 @@ +import os +import re +import json + +from buildbot.schedulers.basic import SingleBranchScheduler, AnyBranchScheduler +from buildbot.schedulers.forcesched import ForceScheduler +from buildbot.schedulers.timed import Nightly + +from buildbot.changes.gitpoller import GitPoller +from buildbot.changes import filter as change_filter + +from buildbot.process.factory import BuildFactory +from buildbot.config import BuilderConfig + +from buildbot.process.properties import renderer +from buildbot.process.properties import Property as P +from buildbot.process.properties import Interpolate as I + +from buildbot.steps.source.git import Git +from buildbot.steps.transfer import FileDownload +from buildbot.steps.shell import ShellCommand +from buildbot.steps.master import SetProperty + +from buildbot.status.results import SUCCESS + +# config +MEDIC_CONFIG_FILE = os.path.join(FP, 'cordova-config.json') +PROJECTS_CONFIG_FILE = os.path.join(FP, 'cordova-repos.json') + +def parse_config_file(file_name): + with open(file_name, 'r') as config_file: + return json.load(config_file) + +medic_config = parse_config_file(MEDIC_CONFIG_FILE) +projects_config = parse_config_file(PROJECTS_CONFIG_FILE) + +# constants +DEFAULT_REPO_NAME = 'src' +BASE_WORKDIR = '.' +TEST_APP_NAME = 'mobilespec' + +OSX = 'osx' +LINUX = 'linux' +WINDOWS = 'windows' + +# patterns +CORDOVA_REPO_PATTERN = r'^.*(cordova-[^\.]+)\.git$' + +# interpretation of every byte-sized return code as success +ALWAYS_SUCCESS = {i: SUCCESS for i in range(0, 256)} + +####### UTILITIES + +# helper functions +def cordova_builders(): + return [b.name for b in c['builders'] if b.name.startswith('cordova-')] + +def repo_name_from_url(url): + match = re.match(CORDOVA_REPO_PATTERN, url) + if match is not None: + return match.group(1) + return DEFAULT_REPO_NAME + +def repo_codebase_from_name(name): + repo = projects_config[name] + codebase_name = repo['codebase'] + return repo['codebases'][codebase_name] + +def repo_url_from_name(name): + return repo_codebase_from_name(name)['repo'] + +def repo_branch_from_name(name): --- End diff -- Even if a function is short, it's a good idea to have it if it can be used in more than one place in the future. Much like a getter method on a class, it separates interface from implementation. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastructure@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org For additional commands, e-mail: dev-help@cordova.apache.org