Skip to content
Permalink
Browse files

give default value for project_name

  • Loading branch information...
sdpython committed Aug 21, 2016
1 parent c65e2cd commit 44d376d3dacf5d4b80e71b82c92a90f8cf96ceb3
@@ -87,8 +87,7 @@ def test_jenkins_job_multiplication(self):
raise FileNotFoundError(yml)
context = dict(Python34="fake", Python35=os.path.dirname(sys.executable),
Python27=None, Anaconda3=None, Anaconda2=None,
WinPython35=None, project_name="pyquickhelper",
root_path="ROOT")
WinPython35=None, root_path="ROOT")
obj = load_yaml(yml, context=context)
res = list(enumerate_convert_yaml_into_instructions(obj))
fLOG(len(res))
@@ -50,7 +50,6 @@ def test_jenkins(self):
Python27="c:\\Python27_x64",
Anaconda3="c:\\Anaconda3", Anaconda2="c:\\Anaconda2",
WinPython35="c:\\PythonENSAE",
project_name="pyquickhelper",
root_path="d:\\jenkins\\yml")
git_repo = "https://github.com/sdpython/pyquickhelper.git"
srv = JenkinsExt("http://localhost:8080/", "user", "password",
@@ -37,8 +37,11 @@ def replace(val, rep, into):
return val.replace(rep, into)
typstr = str # unicode#
if len(file_or_buffer) < 5000 and os.path.exists(file_or_buffer):
path_project = file_or_buffer
with open(file_or_buffer, "r", encoding="utf-8") as f:
file_or_buffer = f.read()
else:
path_project = None

def ospathjoinp(*l, platform=platform):
return ospathjoin(*l, platform=platform)
@@ -52,6 +55,11 @@ def ospathjoinp(*l, platform=platform):
for k, f in fs:
if k not in context:
context[k] = f
if "project_name" not in context and path_project is not None:
fold = os.path.dirname(path_project)
last = os.path.split(fold)[-1]
context["project_name"] = last

file_or_buffer = apply_template(file_or_buffer, context, engine)
return yaml.load(file_or_buffer)

@@ -360,7 +368,7 @@ def add_path_win(rows, interpreter, pip, platform):
def enumerate_processed_yml(file_or_buffer, context=None, engine="jinja2", platform=None,
server=None, git_repo=None, **kwargs):
"""
submit jobs based on the content of a yml file
submit or enumerate jobs based on the content of a yml file
@param file_or_buffer file or string
@param context variables to replace in the configuration
@@ -373,7 +381,19 @@ def enumerate_processed_yml(file_or_buffer, context=None, engine="jinja2", platf
Example of a yml file `.local.jenkins.win.yml <https://github.com/sdpython/pyquickhelper/blob/master/.local.jenkins.win.yml>`_.
"""
project_name = '' if context is None else context.get("project_name", '')
project_name = None if context is None else context.get(
"project_name", None)
if project_name is None:
if len(file_or_buffer) <= 5000 and os.path.exists(file_or_buffer):
fold = os.path.dirname(file_or_buffer)
last = os.path.split(fold)[-1]
project_name = last
if context is not None and "project_name" not in context:
context = context.copy()
context["project_name"] = last
else:
project_name = ''

obj = load_yaml(file_or_buffer, context=context, platform=platform)
for seq, var in enumerate_convert_yaml_into_instructions(obj, variables=context):
conv = convert_sequence_into_batch_file(

0 comments on commit 44d376d

Please sign in to comment.
You can’t perform that action at this time.