Exemple #1
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
Exemple #2
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 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,
    )
Exemple #4
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),
    }
Exemple #5
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)
Exemple #6
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
Exemple #7
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
Exemple #8
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()
Exemple #9
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)
Exemple #10
0
class Main:

    organizer = Organizer()
    so = So()
    directory = so.get_directory()
    organizer.organizer(directory)
Exemple #11
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])
Exemple #12
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)