def clean_urls(self, yaml): urls = re.findall(r'(?:http|https):\/\/(?:[a-zA-Z0-9\.\/]+)', yaml) urls = list(set(urls)) for url in urls: if not url.endswith('/'): yaml = yaml.replace(url, url + '/') return yaml
def test_translate_ui(self): hot_package = self._get_hot_package(self.test_dirs[0]) yaml = hot_package._translate_ui() self.assertIsNotNone(yaml) expected_application = ''' "Application": "?": "classVersion": "1.0.0" "package": "FullTestName" "type": "FullTestName" "name": !yaql "$.group0.name" "templateParameters": "bar": !yaql "$.group1.bar" "baz": !yaql "$.group1.baz" "foo": !yaql "$.group1.foo" ''' self.assertIn(expected_application.replace(' ', '').replace('\n', ''), yaml.replace(' ', '').replace('\n', ''))
def write_app_yaml(app_defn, gae_app_version=None, preamble=None): # set default preamble and GAE app version if preamble is None: preamble = "\n# *** AUTOMATICALLY GENERATED BY FABRIC ***\n" if gae_app_version is None: gae_app_version = 'default' # open template with open(APP_YAML_TEMPLATE_FILENAME)as app_yaml_template_fd: yaml = app_yaml_template_fd.read() # replace placeholders placeholder_replacements = app_defn.items() + [('version', gae_app_version)] for key, val in placeholder_replacements: placeholder_name = ("$%s_PLACEHOLDER" % key).upper() if placeholder_name in yaml: yaml = yaml.replace(placeholder_name, unicode(val)) # write app.yaml with open(APP_YAML_FILENAME, 'w') as app_yaml_fd: app_yaml_fd.write(preamble) app_yaml_fd.write(yaml)