曾与蒿藜同雨露,한때 잡초와 쑥과 함께 비와 이슬을 나누던 곳이 이제는 소나무와 삼나무와 함께 서리와 눈을 견뎌내고 있다.终随松柏到冰霜.かつては雑草やヨモギと共に雨や露を分かち合っていたが、今では松やヒノキと共に霜や雪に耐えている。曾与蒿藜同雨露,Once sharing rain and dew with weeds and wormwood, now enduring frost and snow with pines and cypresses.终随松柏到冰霜.曾与蒿藜同雨露한때 잡초와 쑥과 함께 비와 이슬을 나누던 곳이 이제는 소나무와 삼나무와 함께 서리와 눈을 견뎌내고 있다.,终随松柏到冰霜.譖セ荳手珍阯懷酔髮ィ髴イ�檎サ磯囂譚セ譟丞芦蜀ー髴�曾与蒿藜同雨露,鏇句笌钂胯棞鍚岄洦闇诧紝缁堥殢鏉炬煆鍒板啺闇�终随松柏到冰霜.曾与蒿藜同雨露,한때 잡초와 쑥과 함께 비와 이슬을 나누던 곳이 이제는 소나무와 삼나무와 함께 서리와 눈을 견뎌내고 있다.终随松柏到冰霜.曾与蒿藜同雨露,终随松柏到冰霜.
#
# Copyright (c) 1999--2012 Red Hat, Inc.
#
# This software is licensed to you under the GNU General Public License,
# version 2 (GPLv2). There is NO WARRANTY for this software, express or
# implied, including the implied warranties of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
# along with this software; if not, see
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
#
# Red Hat trademarks are not licensed under GPLv2. No permission is
# granted to use or replicate Red Hat trademarks that are incorporated
# in this software or its documentation.
#
""" Query hwdata database and return decription of vendor and/or device. """
class USB:
""" Interace to usb.ids from hwdata package """
filename = '/usr/share/hwdata/usb.ids'
devices = None
def __init__(self, filename=None):
""" Load pci.ids from file to internal data structure.
parameter 'filename' can specify location of this file
"""
if filename:
self.filename = filename
else:
self.filename = USB.filename
self.cache = 1
if self.cache and not USB.devices:
# parse usb.ids
USB.devices = {}
for line in open(self.filename).readlines():
l = line.split()
if line.startswith('#'):
if line.startswith('# List of known device classes, subclasses and protocols'):
break # end of database of devices, rest is protocols, types etc.
else:
continue
elif len(l) == 0:
continue
elif line.startswith('\t\t'):
interface_id = l[0].lower()
if len(l) > 2:
interface_name = ' '.join(l[1:])
else:
interface_name = ''
USB.devices[vendor][1][device][0][interface_id] = interface_name
elif line.startswith('\t'):
device = l[0].lower()
device_name = ' '.join(l[1:])
USB.devices[vendor][1][device] = [device_name, {}]
else:
vendor = l[0].lower()
vendor_name = ' '.join(l[1:])
if vendor not in USB.devices:
USB.devices[vendor] = [vendor_name, {}]
else: # this should not happen
USB.devices[vendor][0] = vendor_name
def get_vendor(self, vendor):
""" Return description of vendor. Parameter is two byte code in hexa.
If vendor is unknown None is returned.
"""
vendor = vendor.lower()
if self.cache:
if vendor in USB.devices:
return USB.devices[vendor][0]
else:
return None
else:
raise # not implemented yet
def get_device(self, vendor, device):
""" Return description of device. Parameters are two byte code variables in hexa.
If device is unknown None is returned.
"""
vendor = vendor.lower()
device = device.lower()
if self.cache:
if vendor in USB.devices:
if device in USB.devices[vendor][1]:
return USB.devices[vendor][1][device][0]
else:
return None
else:
return None
else:
raise # not implemented yet
class PCI:
""" Interace to pci.ids from hwdata package """
filename = '/usr/share/hwdata/pci.ids'
devices = None
def __init__(self, filename=None):
""" Load pci.ids from file to internal data structure.
parameter 'filename' can specify location of this file
"""
if filename:
self.filename = filename
else:
self.filename = PCI.filename
self.cache = 1
if self.cache and not PCI.devices:
# parse pci.ids
pcirec = {}
PCI.devices = {}
for line in open(self.filename).readlines():
l = line.split()
if line.startswith('#'):
continue
elif len(l) == 0:
continue
elif line.startswith('\t\t'):
continue
elif line.startswith('\t'):
device = l[0].lower()
device_name = ' '.join(l[1:])
PCI.devices[vendor][1][device] = device_name
else:
vendor = l[0].lower()
vendor_name = ' '.join(l[1:])
if not vendor in list(PCI.devices.keys()):
PCI.devices[vendor] = [vendor_name, {}]
else: # this should not happen
PCI.devices[vendor][0] = vendor_name
def get_vendor(self, vendor):
""" Return description of vendor. Parameter is two byte code in hexa.
If vendor is unknown None is returned.
"""
vendor = vendor.lower()
if self.cache:
if vendor in list(PCI.devices.keys()):
return PCI.devices[vendor][0]
else:
return None
else:
raise # not implemented yet
def get_device(self, vendor, device):
""" Return description of device. Parameters are two byte code variables in hexa.
If device is unknown None is returned.
"""
vendor = vendor.lower()
device = device.lower()
if self.cache:
if vendor in list(PCI.devices.keys()):
if device in list(PCI.devices[vendor][1].keys()):
return PCI.devices[vendor][1][device]
else:
return None
else:
return None
else:
raise # not implemented yet