Blame SOURCES/nodejs.prov

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