Example #1
0
        def runUnitTest ():
            os.system('cls')
            print 'Running DesignComponent.UnitTest...\n'
            Sourcerer.printLine('-')

            DesignComponent.UnitTest.testDownloadDesignFiles()
            
            Sourcerer.printLine('-')
            print 'Finished running DesignComponent.UnitTest.'
Example #2
0
 def isDesignDocument(url):
     filetype = Sourcerer.getFiletype(url)
     if filetype == '':
         return
     if filetype in DesignComponent.documentTypes:
         return True
     return False
Example #3
0
 def downloadDesignFiles(self):
     directory = self.directory
     Sourcerer.checkPathOrCreate(direcotry)
     Sourcerer.downloadFile(self.datasheetURL, directory)
     
     metadata = self.metadata
     for key in metadata:
         if key.endswith(' URL'):
             self.downloadDesignFile(metadata[key])
             self.downloadDocument(metadata[key])
     
     for source in self.sources:
         for key, value in source.metadata:
             if ' URL' in key:
                 self.downloadDesignFile(value)
                 self.downloadDocument(value)
Example #4
0
    def addMetadata(self, key, value):
        key = key.strip()
        if key == '': # We can't add a entry with no key.
            return
        
        if key.endswith(' URL'):
            value = Sourcerer.fixShortURL(value)
        
        #print 'Adding metadata: ', key, ', ', value
        print 'Adding metadata entry: [" ', key, ' "], [" ', value, ' "]'
        
        if len(self.metadata) == 0: # We have to create a dictionary
            self.metadata = { key: value }
            return

        self.metadata[key] = value
Example #5
0
 def generateTestComponent(manufacturer, name, directory):
     print 'Generating test DesignComponent...("', name, ', ', manufacturer, ', ', directory, ')\n'
     
     component = DesignComponent(manufacturer, name, directory)
     component.datasheetURL = Sourcerer.fixShortURL('www.genericmanufacturer.com/test/1/2/3/datasheet.pdf')
     
     component.addMetadata('3D Model URL', 'http://www.molex.com/pdm_docs/stp/87918-0001_stp.zip')
     component.addMetadata('Datasheet 1 URL', 'http://www.molex.com/pdm_docs/sd/879180001_sd.pdf')
     component.addMetadata('3D Model 2 URL', 'http://www.te.com/commerce/DocumentDelivery/DDEController?Action=srchrtrv&DocNm=640454-4&DocType=Customer+View+Model&DocLang=English')
     component.addMetadata('Datasheets 2 URL', 'http://www.te.com/commerce/DocumentDelivery/DDEController?Action=srchrtrv&DocNm=640454&DocType=Customer+Drawing&DocLang=English')
     component.addMetadata('Online Catalog URL', 'http://www.digikey.com/catalog/en/partgroup/mta-100-series/9332?mpart=640454-4&vendor=17&WT.z_ref_page_type=PS&WT.z_ref_page_sub_type=PD&WT.z_ref_page_id=PD&WT.z_ref_page_event=DC_Link_Table')
     component.addMetadata('Product Photos URL', 'http://media.digikey.com/photos/Tyco%20Amp%20Photos/640456-4,%20640454-4.jpg')
     component.addMetadata('Featured Product URL', 'http://www.digikey.com/product-highlights/us/en/te-connectivity-mta-connectors/2307')
     component.addMetadata('Series URL', 'http://www.digikey.com/product-search/en?FV=ffec1142')
     
     return component
Example #6
0
        def testDownloadDesignFiles():
            print '\nRunning DesignComponent diagnostics...'
            Sourcerer.printLine('-')

            testDirectoryName = 'D:\Workspace\eda-sourcerer\source\Test' # already existing folder on D: drive
            component = DesignComponent.UnitTest.generateTestComponent('TestComponent', 'Generic', testDirectoryName)
            print component.toString()
            
            Sourcerer.printLine('-');
            print '\nDownloading test files...'
            component.downloadDesignFiles()
            
            Sourcerer.printLine('-')
            print 'Finished running DesignComponent diagnostics.\n'
Example #7
0
 def __init__(self, projectDirectory):
     HTMLParser.__init__(self)
     self.projectDirectory = Sourcerer.cleanDirecoryPath(projectDirectory)
Example #8
0
 def loadFromURL(self, supplyCode, delineator, url):
     htmlDoc = Sourcerer.loadContentFromURL(url)
     self.loadFromHTML(supplyCode, delineator, htmlDoc, url)
Example #9
0
 def setName(self, name):
     properName = Sourcerer.fixFilename(name)
     if properName == '': # The name was not valid.
         return
     self.name = name
Example #10
0
 def setManufacturer(self, manufacturer):
     properName = Sourcerer.fixFilename(manufacturer)
     if properName == '': # The name was not valid.
         return
     self.manufacturer = manufacturer
Example #11
0
 def testGenerateDesignComponent():
     
     print '\nRunning testGenerateDesignComponent diagnostics...'
     Sourcerer.printLine('-')
     
     testDirectoryName = 'D:\Workspace\eda-sourcerer\source\Test' # already existing folder on D: drive
     
     component = DesignComponent.UnitTest.generateTestComponent('TestComponent', 'Generic', testDirectoryName)
     
     Sourcerer.printLine('-')
     print '\n', component.toString()
     Sourcerer.printLine('-')
     
     badFolderName = 'B:\ad\direcotry' # Folder that does not exist
     component = DesignComponent.UnitTest.generateTestComponent('TestComponent', 'Generic', badFolderName)
     
     Sourcerer.printLine('-')
     print '\n', component.toString()
     Sourcerer.printLine('-')
     
     component.downloadDesignFiles()
     
     Sourcerer.printLine('-')
     print 'Finished running testGenerateDesignComponent diagnostics.\n'
Example #12
0
 def downloadDesignFile(self, url):
     if not DesignComponent.isDesignDocument(url):
         return
     Sourcerer.downloadFile(url, DesignComponent.designFileTypes)