Blame SOURCES/nodejs.prov

6be2b1
#!/usr/bin/python
6be2b1
6be2b1
"""
6be2b1
Automatic provides generator for Node.js libraries.
6be2b1
6be2b1
Taken from package.json.  See `man npm-json` for details.
6be2b1
"""
6be2b1
# Copyright 2012 T.C. Hollingsworth <tchollingsworth@gmail.com>
6be2b1
#
6be2b1
# Permission is hereby granted, free of charge, to any person obtaining a copy
6be2b1
# of this software and associated documentation files (the "Software"), to
6be2b1
# deal in the Software without restriction, including without limitation the
6be2b1
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
6be2b1
# sell copies of the Software, and to permit persons to whom the Software is
6be2b1
# furnished to do so, subject to the following conditions:
6be2b1
#
6be2b1
# The above copyright notice and this permission notice shall be included in
6be2b1
# all copies or substantial portions of the Software.
6be2b1
#
6be2b1
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
6be2b1
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
6be2b1
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
6be2b1
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
6be2b1
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
6be2b1
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
6be2b1
# IN THE SOFTWARE.
6be2b1
6be2b1
import json
6be2b1
import subprocess
6be2b1
import sys
6be2b1
6be2b1
paths = [path.rstrip() for path in sys.stdin.readlines()]
6be2b1
6be2b1
for path in paths:
6be2b1
    if path.endswith('package.json'):
6be2b1
        fh = open(path)
6be2b1
        metadata = json.load(fh)
6be2b1
        fh.close()
6be2b1
6be2b1
        if 'name' in metadata and not ('private' in metadata and metadata['private']):
6be2b1
            print 'rh-nodejs6-npm(' + metadata['name'] + ')',
6be2b1
6be2b1
            if 'version' in metadata:
6be2b1
                print '= ' + metadata['version']
6be2b1
            else:
6be2b1
                print
6be2b1
6be2b1
# invoke the regular RPM provides generator                
6be2b1
p = subprocess.Popen(['/usr/lib/rpm/find-provides'], stdout=subprocess.PIPE, stdin=subprocess.PIPE)
6be2b1
print p.communicate(input='\n'.join(paths))[0]