1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-02-26 12:12:11 +01:00

- added 'file_ext' key to the metatypes dict(). This key contains the filename extension for the particular metatype. This way we achieve that each metatype has the correct syntax highliting when running "osc meta -e <metatype>..." (e.g. prjconf => .txt, pkg => .xml etc.)

This commit is contained in:
Marcus Hüwe 2008-05-20 09:23:57 +00:00
parent d80c47c0b9
commit aba87c08dd

View File

@ -1565,13 +1565,13 @@ def show_pattern_meta(apiurl, prj, pattern):
class metafile: class metafile:
"""metafile that can be manipulated and is stored back after manipulation.""" """metafile that can be manipulated and is stored back after manipulation."""
def __init__(self, url, input, change_is_required=False): def __init__(self, url, input, change_is_required=False, file_ext='.xml'):
import tempfile import tempfile
self.url = url self.url = url
self.change_is_required = change_is_required self.change_is_required = change_is_required
(fd, self.filename) = tempfile.mkstemp(prefix = 'osc_metafile.', suffix = '.xml', dir = '/tmp') (fd, self.filename) = tempfile.mkstemp(prefix = 'osc_metafile.', suffix = file_ext, dir = '/tmp')
f = os.fdopen(fd, 'w') f = os.fdopen(fd, 'w')
f.write(''.join(input)) f.write(''.join(input))
@ -1616,18 +1616,23 @@ class metafile:
# different types of metadata # different types of metadata
metatypes = { 'prj': { 'path': 'source/%s/_meta', metatypes = { 'prj': { 'path': 'source/%s/_meta',
'template': new_project_templ, 'template': new_project_templ,
'file_ext': '.xml'
}, },
'pkg': { 'path' : 'source/%s/%s/_meta', 'pkg': { 'path' : 'source/%s/%s/_meta',
'template': new_package_templ, 'template': new_package_templ,
'file_ext': '.xml'
}, },
'prjconf': { 'path': 'source/%s/_config', 'prjconf': { 'path': 'source/%s/_config',
'template': '', 'template': '',
'file_ext': '.txt'
}, },
'user': { 'path': 'person/%s', 'user': { 'path': 'person/%s',
'template': new_user_template, 'template': new_user_template,
'file_ext': '.xml'
}, },
'pattern': { 'path': 'source/%s/_pattern/%s', 'pattern': { 'path': 'source/%s/_pattern/%s',
'template': new_pattern_template, 'template': new_pattern_template,
'file_ext': '.xml'
}, },
} }
@ -1691,7 +1696,7 @@ def edit_meta(metatype,
change_is_required = True change_is_required = True
url = make_meta_url(metatype, path_args, apiurl) url = make_meta_url(metatype, path_args, apiurl)
f=metafile(url, data, change_is_required) f=metafile(url, data, change_is_required, metatypes[metatype]['file_ext'])
if edit: if edit:
editor = os.getenv('EDITOR', default='vim') editor = os.getenv('EDITOR', default='vim')