Exemplo n.º 1
0
def ProcessData(DataPath):
    global LisOfPeople
    '''
        encode all faces
    '''
    options = []
    path = (DataPath)
    usb = os.listdir(path)
    #insert path to usb
    #print(usb)
    if 'FaceData.txt' in usb:
        text_file = read_text_file(os.path.join(path, 'FaceData.txt'))
        options = text_file.splitlines()
    if 'NoChange' in options:
        '''
            conditions to not encode faces and just read in an existing data set
        '''
    for folder in usb:
        #get folder name and assign that to the person
        #print(folder)
        if not folder.endswith(
            ('.txt', '.dat', '.jpg',
             '.jpeg')) and folder != 'System Volume Information':
            CurEncodings = []
            PersonIdentity = folder
            DataPath = os.path.join(path, folder)
            Information = os.listdir(DataPath)
            UniqueID = uuid.uuid4()
            Info = ''
            img = []
            for data in Information:
                '''
                    start assigning datas
                '''
                #print(data)
                if data.endswith(('.jpg', '.jpeg', '.png')):
                    to_encode = face_recognition.load_image_file(
                        os.path.join(DataPath, data))
                    CurEncodings.append(
                        face_recognition.face_encodings(to_encode)[0])
                    img = cv2.imread(data)
                if (data == 'Data.txt'):
                    '''
                    '''
                    Info = read_text_file(os.path.join(DataPath, 'Data.txt'))

            #tbc
            ListOfPeople.append(
                Classes.person(PersonIdentity, CurEncodings, UniqueID, Info,
                               img))
Exemplo n.º 2
0
def test_egg_info_data(file_contents, expected):
    om = mock_open(read_data=file_contents)
    em = Mock()
    em.return_value = 'cp1252'
    with patch('pip._internal.utils.misc.open', om, create=True):
        with patch('locale.getpreferredencoding', em):
            ret = read_text_file('foo')
    assert ret == expected.decode('utf-8')
Exemplo n.º 3
0
def test_egg_info_data(file_contents, expected):
    om = mock_open(read_data=file_contents)
    em = Mock()
    em.return_value = 'cp1252'
    with patch('pip._internal.utils.misc.open', om, create=True):
        with patch('locale.getpreferredencoding', em):
            ret = read_text_file('foo')
    assert ret == expected.decode('utf-8')
 def egg_info_data(self, filename):
     if self.satisfied_by is not None:
         if not self.satisfied_by.has_metadata(filename):
             return None
         return self.satisfied_by.get_metadata(filename)
     assert self.source_dir
     filename = self.egg_info_path(filename)
     if not os.path.exists(filename):
         return None
     data = read_text_file(filename)
     return data
Exemplo n.º 5
0
 def egg_info_data(self, filename):
     if self.satisfied_by is not None:
         if not self.satisfied_by.has_metadata(filename):
             return None
         return self.satisfied_by.get_metadata(filename)
     assert self.source_dir
     filename = self.egg_info_path(filename)
     if not os.path.exists(filename):
         return None
     data = read_text_file(filename)
     return data