def test_valid_type_organization(self):
        file_list = ['file.doc', 'file.docx', 'file.pdf',
                     'song.mp3', 'song.wav',
                     'some torrent.torrent',
                     'picture.png', 'picture.jpg',
                     'exec.exe', 'exec.bin', 'exec.app',
                     'exec.osx', 'exec.msi',
                     'presentation.pptx']

        organizer = Organizer('C:')
        organizer.file_list = file_list

        files_by_type = organizer.organize_by_type()

        self.assertCountEqual(files_by_type['Documents'],
                                           ['file.doc', 'file.docx',
                                            'file.pdf'])
        self.assertCountEqual(files_by_type['Music'],
                                           ['song.wav', 'song.mp3'])
        self.assertCountEqual(files_by_type['Torrents'],
                                           ['some torrent.torrent'])
        self.assertCountEqual(files_by_type['Pictures'],
                                           ['picture.png', 'picture.jpg'])
        self.assertCountEqual(files_by_type['Executables'],
                                           ['exec.exe', 'exec.bin',
                                            'exec.app', 'exec.osx',
                                            'exec.msi'])
        self.assertCountEqual(files_by_type['Presentations'],
                                           ['presentation.pptx'])
Example #2
0
class Client:

    def __init__(self, config: ConfigurationFile):
        self.config = config
        self.database = Database(self.config.db_file)
        self.organizer = Organizer(self.config, self.config.db_file)
        self.downloader = Downloader(self.config.db_file, self.organizer,
                                     self.config)
        self.tracker = Tracker(self.config.db_file, self.downloader,
                               self.config.update_period)

        self.tracker.start()
        self.downloader.start()
        self.organizer.start()

    def add_tvshow(self, tvshow_id: int):
        tvshow_name = showrss.get_name(tvshow_id)
        self.database.put_tvshow(TVShow(tvshow_id, tvshow_name))

    def remove_tvshow(self, tvshow_id: int):
        self.database.remove_tvshow(tvshow_id)

    def list_tvshows(self):
        return self.database.tvshows()

    def list_episodes(self, state: EpisodeState = None):
        return self.database.episodes(state)

    def download_progress(self):
        return self.downloader.downloads()

    def exit(self):
        self.tracker.stop()
        self.downloader.stop()
Example #3
0
 def run(self, edit):
     try:
         settings = sublime.load_settings("python_imports_sorter.sublime-settings")
         project_modules = ['sublime', 'sublime_plugin']
         additional_modules = settings.get('project_modules', [])
         if additional_modules:
             project_modules.extend(additional_modules)
         sublime.status_message('Formatting imports...')
         line_endings = self.view.line_endings()
         if line_endings == 'windows':
             delimiter = '\r\n'
         elif line_endings == 'mac':
             delimiter = '\r'
         elif line_endings == 'linux':
             delimiter = '\n'
         else:
             delimiter = '\n'
         contents = self.view.substr(self.view.full_line(self.view.sel()[0]))
         o = Organizer(contents, delimiter, project_modules)
         new_content = o.reorganize()
         if st3:
             self.view.replace(edit, r=self.view.full_line(self.view.sel()[0]), text=new_content)
         else:
             self.view.replace(edit, self.view.full_line(self.view.sel()[0]), new_content)
         sublime.status_message('Imports have been formatted.')
     except Exception:
         sublime.error_message(traceback.format_exc())
         raise
 def organizer(self, cache_dir, store_dir, mocker):
     config = Configurator(str(cache_dir), str(store_dir))
     mocker.patch.object(Database, 'set_state')
     organizer = Organizer(config, Database)
     episode = Episode("Title", 1, 1, False, "link")
     organizer.store(episode)
     return organizer
Example #5
0
def main():
    # db_file_name = input("DB filename: ").strip() or ".temp.db"
    # organizer_root = input("Gallery root: ").strip() or "data"
    db_file_name = ".temp.db"
    organizer_root = "data"
    # os.remove(db_file_name)
    organizer = Organizer(organizer_root, db_file_name)
    organizer.analyze_root()
    def test_valid_extension_organization(self):
        file_list = ['file1.docx',
                     'file2.exe.exe', 'file3.docx.exe',
                     'file5.sdx',
                     'some.power']
        organizer = Organizer('C:')
        organizer.file_list = file_list

        files_by_extensions = organizer.organize_by_extension()

        self.assertCountEqual(files_by_extensions['exe'], ['file2.exe.exe',
                                                           'file3.docx.exe'])
        self.assertCountEqual(files_by_extensions['docx'], ['file1.docx'])
        self.assertCountEqual(files_by_extensions['power'], ['some.power'])
def mocks(mocker, sample_root_path):
    mock_db_inst = mocker.Mock()
    mock_db_inst_class = mocker.patch("organizer.DBInstance", return_value=mock_db_inst)
    org = Organizer(sample_root_path, "dummy_db_path")

    return SimpleNamespace(
        org=org,
        mock_db_inst=mock_db_inst,
        mock_db_inst_class=mock_db_inst_class,
    )
Example #8
0
    def __init__(self, config: ConfigurationFile):
        self.config = config
        self.database = Database(self.config.db_file)
        self.organizer = Organizer(self.config, self.config.db_file)
        self.downloader = Downloader(self.config.db_file, self.organizer,
                                     self.config)
        self.tracker = Tracker(self.config.db_file, self.downloader,
                               self.config.update_period)

        self.tracker.start()
        self.downloader.start()
        self.organizer.start()
    def reorganize(self, type_of_reorganization):
        """
        Reorganizes the directory by copying its files
        to their respective destinations determined by the
        organization type. Creates a docx report with
        information about the copied files
        """
        organizer = Organizer(self.source_folder_path)
        organization = defaultdict(list)

        if type_of_reorganization == 'extension':
            organization = organizer.organize_by_extension()

        if type_of_reorganization == 'type':
            organization = organizer.organize_by_type()

        if type_of_reorganization == 'content':
            organization = organizer.organize_by_content(self.match_strings)

        # create folder named as the type of organization (extension,content..)
        type_folder = self.target_folder_path + "\\" + type_of_reorganization
        if os.path.exists(type_folder) is False:
            os.mkdir(type_folder)

        self.create_new_dirs(organization, type_folder)

        # create report
        doc_handler = DocumentHandler()

        # a log dictionary, holding the copied filenames and their destination
        log = {}

        for folder_name in organization:
            self.copy_files(organization[folder_name],
                            type_folder + "\\" + folder_name)
            for file in organization[folder_name]:
                destination = type_folder + "\\" + folder_name
                log[file] = destination

        report = doc_handler.create_report(self.target_folder_path, log)
def main():

    talks = []

    talks = feed_talks()
    
    organizer = Organizer()

    results = organizer.organize(talks, [180, 240, 180, 240])

    track = 1

    for (index, session) in enumerate(results, start = 1):
        if index % 2:
            print 'Track {0}'.format(track)
            curr_datetime = datetime.datetime(
                2015,
                4,
                5,
                9,
                0,
                0,
                )
        if not index % 2:
            curr_datetime = datetime.datetime(
                2015,
                4,
                5,
                13,
                0,
                0,
                )
            track = track + 1
        for talk in session.talks:
            print '{0:02d}:{1:02d} {2}'.format(curr_datetime.hour,
                                       curr_datetime.minute,
                                       talk.description)
            resultant_time = curr_datetime + datetime.timedelta(minutes=talk.length)
            curr_datetime = resultant_time
Example #11
0
 def __create_organizer(self, target_path, recorded_path):
     """ creates an organizer at new destination path or modifies the
     old one """
     # TODO : find a proper fix for the following hack
     # We avoid creating new instances of organize because of the way
     # it interacts with pydispatch. We must be careful to never have
     # more than one instance of OrganizeListener but this is not so
     # easy. (The singleton hack in Organizer) doesn't work. This is
     # the only thing that seems to work.
     if self.organize['organizer']:
         o               = self.organize['organizer']
         o.channel       = self.organize_channel
         o.target_path   = target_path
         o.recorded_path = recorded_path
     else:
         self.organize['organizer'] = Organizer(channel=
                 self.organize_channel, target_path=target_path,
                 recorded_path=recorded_path)
Example #12
0
def start():
    clearScr()

    print("J-SUD's crappy organizer prototype\n v0.0.0.0.001")

    # If there are saves and we want to use them
    if os.path.exists("saves/data.dat"):
        inp = input("Use saved data? (will overwrite if no) y/n: ")
        if inp == "y":
            clearScr()
            with open("saves/data.dat", "r+b") as f:
                return pickle.load(f)
    # If there are no saves
    else:
        input("Press enter to continue:")

    # No saves or user doesn't care
    clearScr()
    org = Organizer()
    return org
Example #13
0
def test_organizer_entity_scanning(sample_root_path, tmp_path):
    organizer = Organizer(sample_root_path, tmp_path / "sample.db")
    organizer.analyze_root()

    assert len(organizer.get_all_entities()) == 9
    names = {(entity.name, entity.type_)
             for entity in organizer.get_all_entities().values()}
    assert names == {
        ("file1", EntityTypeId.Unkown),
        ("file2.txt", EntityTypeId.Unkown),
        ("file3.jpg", EntityTypeId.Image),
        ("file4.gif", EntityTypeId.Gif),
        ("file5.mp4", EntityTypeId.Video),
        ("file6.png", EntityTypeId.Image),
        ("sub1", EntityTypeId.Gallery),
        ("sub2file1", EntityTypeId.Unkown),
        ("sub2file2.flv", EntityTypeId.Video),
    }
Example #14
0
print("Dataset values:")

# Show the data (the attributes of each instance)
print(irisDataset.data)

# Show the target values (in numeric format) of each instance
print(irisDataset.target)

# Show the actual target names that correspond to each number
print(irisDataset.target_names)

print("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++")

#organize and get the data back from the Organizer
workingDatasets = Organizer(irisDataset).organize_data()

# printing the shuffled sets
for i in range(len(workingDatasets[0])):
    print("Training set: ", workingDatasets[0][i].target)
print("-------------------------")
for i in range(len(workingDatasets[1])):
    print("Testing set: ", workingDatasets[1][i].target)
print("--------------------------------------------------------------")

# IT'S ALIIIIIIVE
Iris = Iris()

# Train that thang
Iris.train(workingDatasets[0])
Example #15
0
from organizer import Organizer
from create_db import Data_base
organizer_instance = Organizer('Szymon Sleczka')
db = Data_base()
while True:
    print('What do you want to do? \n'
          '1. Add Note \n'
          '2. Add Business Card \n'
          '3. Add Discount Coupon \n'
          '4. Display notes \n'
          '5. Display Business Cards \n'
          '6. Display Discount Coupon \n'
          '7. Create db \n'
          '8. Display db \n'
          '9. Delte item R\n'
          '10. Exit')

    inpt = int(input())

    if inpt == 1: organizer_instance.add_note()
    if inpt == 2: organizer_instance.add_business_card()
    if inpt == 3: organizer_instance.add_discount_coupon()
    if inpt == 4: organizer_instance.display_notes()
    if inpt == 5: organizer_instance.display_bsns_card()
    if inpt == 6: organizer_instance.display_discount_coupon()
    if inpt == 7: db.create_db(organizer_instance.get_db())
    if inpt == 8: db.disp_db()
    if inpt == 9: organizer_instance.delete_display()
    if inpt == 10: break
Example #16
0
from organizer import Organizer

my_organizer = Organizer('Piotr')

while True:

    print('''What would you like to do:

        Note:        Business card:    Discount code:
    1 - add       |   4 - add       |   7 - add
    2 - display   |   5 - display   |   8 - display
    3 - delete    |   6 - delete    |   9 - delete  
                  0 - close organizer    
    ''')

    x = input()
    try:
        if x == '1':
            my_organizer.add_note()
        if x == '2':
            my_organizer.display_notes()
        if x == '3':
            my_organizer.detele_note()
        if x == '4':
            my_organizer.add_business_card()
        if x == '5':
            my_organizer.display_business_cards()
        if x == '6':
            my_organizer.delete_business_card()
        if x == '7':
            my_organizer.add_discount_code()
Example #17
0
import socketio, html, json

from organizer import Organizer
from game import Character

organizer = Organizer()

sio = socketio.AsyncServer()


@sio.event
def connect(sid, environ):
    print("Connected: ", sid)


@sio.event
async def disconnect(sid):
    print('Disconnected: ', sid)
    await organizer.disconnect(sid)


@sio.event
def update_user(sid, uname, team):
    # TODO disallow updating of team
    print('Update user: ', sid)
    organizer.updateUser(sid, html.escape(uname), team)


@sio.event
async def joinroom(sid, roomid):
    room = organizer.getRoomById(roomid)
Example #18
0
from organizer import Organizer
from rest_api.app import get_flask_app


def main():
    # db_file_name = input("DB filename: ").strip() or ".temp.db"
    # organizer_root = input("Gallery root: ").strip() or "data"
    db_file_name = ".temp.db"
    organizer_root = "data"
    # os.remove(db_file_name)
    organizer = Organizer(organizer_root, db_file_name)
    organizer.analyze_root()
    # print(organizer.get_entities())
    # print(organizer.get_types())
    # print(organizer.get_groupings())
    # print(organizer.get_groups())
    # print(organizer.get_file_name("0d5a577a45c97e9741182c062cef189a5c852964"))
    # print(organizer.get_file_name("72ee847ea13f7fe0f15a577868855d7e4a5f4000"))


if __name__ == '__main__':
    # main()
    db_file_name = "tmp-data/sample.db"
    organizer_root = "tmp-data/sample_root"
    organizer = Organizer(organizer_root, db_file_name)
    # print("analyzing root")
    # organizer.analyze_root()
    # print("analyzed root")
    app = get_flask_app(organizer)
    app.run(debug=False, port=9001)
Example #19
0
from kivymd.app import MDApp
from kivy.lang import Builder
from kivymd.uix.dialog import MDDialog
from kivymd.uix.button import MDFlatButton
from kivy.uix.boxlayout import BoxLayout
from kivymd.uix.screen import Screen
from kivymd.uix.button import MDRectangleFlatButton
from organizer import Organizer
from create_db import Data_base
organizer_instance = Organizer('Szymon Sleczka')
db = Data_base()
KV = '''
Screen:
    MDLabel:
        text: "This is organizer app"
        pos_hint: {'center_x':0.5,'center_y':0.9}
        halign:"center"
        
        
    FloatLayout:
    
        MDRaisedButton:
            text: "Add Note"
            md_bg_color: 0.4, 1, 0.2, 1
            size_hint: 0.25, 0.08
            pos_hint: {'center_x':0.3,'center_y':0.8}
            on_release: app.show_confirmation_dialog()
        
        
        MDRaisedButton:
            text: "Add business card"
Example #20
0
class Main:

    organizer = Organizer()
    so = So()
    directory = so.get_directory()
    organizer.organizer(directory)