示例#1
0
 def mkFile(self, name):  #this is for creating a file inside this directory
     name = name.split(".")
     if len(
             name
     ) < 2:  #this is a check to add the .txt if no filetype is provided
         name[1] = "txt"
     fullnamae = name[0] + "." + name[1]
     if self.findId(
             fullnamae
     ) == -1:  #if there is no file whit this name here do this
         tempFile = mkFileFunc(name, self.directory + [self.name])
         self.content[fullnamae] = tempFile
     else:  #else if there is a file whit this name do this
         print("That file aleardy exists")
示例#2
0
    def IntVar(self, floo, cei, name):
        if type(name) == tuple:
            store_name = name[0]
            card_name = name[1]
            name = store_name[0:31] + '|' + card_name[0:32]
        else:
            tmp = name.split('|')
            store_name = tmp[0]
            if len(tmp) == 2:
                card_name = tmp[1]
            else:
                card_name = tmp[0]

        exit = super().IntVar(floo, cei, name)
        exit.store_name = store_name
        exit.card_name = card_name
        return exit
示例#3
0
def import_name_or_class(name):
    " Import an obect as either a fully qualified, dotted name, "

    if isinstance(name, str):

        # for "a.b.c.d" -> [ 'a.b.c', 'd' ]
        module_name, object_name = name.rsplit('.', 1)
        # __import__ loads the multi-level of module, but returns
        # the top level, which we have to descend into
        mod = __import__(module_name)

        components = name.split('.')

        for comp in components[1:]:  # Already got the top level, so start at 1

            mod = getattr(mod, comp)
        return mod
    else:
        return name  # Assume it is already the thing we want to import
def save_as():
    file_name = filedialog.asksaveasfilename(
        defaultextension="*.txt",
        initialdir="C:/Users/Aniket thani/Desktop/Tkinter tutorial/",
        title="Save File",
        filetypes=(("Text File", "*.txt"), ("HTML File", "*.html"),
                   ("Python File", "*.py"), ("All Files", "*.*")))

    if file_name:
        #update the title and status bar
        name = file_name
        status_bar.config(text="Saved : " + file_name)
        name = name.split("/")[-1]
        root.title(f'Text Editor By Aniket Thani : {name}')

        #save file
        f = open(file_name, "w")
        f.write(textbox.get(1.0, END))
        f.close()
        global name_of_file_open
        name_of_file_open = file_name
def open_file():
    textbox.delete(1.0, END)
    file = filedialog.askopenfilename(filetypes=(("Text File", "*.txt"),
                                                 ("HTML File", "*.html"),
                                                 ("Python File", "*.py"),
                                                 ("All Files", "*.*")))
    global name_of_file_open
    if file:
        name_of_file_open = file

    #update title and status bar
    name = file
    status_bar.config(text=file)
    name = name.split("/")[-1]
    root.title(f'Text Editor By Aniket Thani : {name}')

    #open file
    file = open(file, "r")
    stuff = file.read()
    textbox.insert(END, stuff)
    file.close()
示例#6
0
 def rename(self, name, newname):  #function for renaming dirs and files
     if self.findId(name) != -1:  # if exists
         if self.content[name].fileType == "Dir":  #if its a dir
             if not self.content[name].content:  # if is not empty
                 print(
                     "The names of directories that are not empty cannot be changed"
                 )
             else:  #if its empty
                 self.content[name].name = newname
                 self.content[newname] = self.content[name]
                 del self.content[name]
         else:  #if its a file
             newname = newname.split(".")
             if len(
                     newname
             ) < 2:  #this is a check to add the old if no filetype is provided
                 newname[1] = name.split(".")[1]
             newfullnamae = newname[0] + "." + newname[1]
             self.content[name].name = newname[0]
             self.content[name].fileType = newname[1]
             self.content[newfullnamae] = self.content[name]
             del self.content[name]
示例#7
0
tmp_creator = {}

with open(FILE) as f:
    for line in f:
        name = ""
        orcid = ""
        affil = ""
        name, orcid, affil1 = line.split(
            ','
        )  # here we must check that an ORCID exists! It might not? User may not have one!
        # if not orcid:
        #     print 'ORCID is empty...',orcid;
        # else:
        #     print 'ORCID is ...',orcid;
        affil = affil1.rstrip()
        family_name, first_name = name.split(
            ' ')  # here we have a problem if double last or first name!
        final_name = family_name + ', ' + first_name
        # What to do??? otherwise
        tmp_creator['name'] = final_name
        if orcid:
            tmp_creator['orcid'] = orcid
        tmp_creator['affiliation'] = affil
        creators.append(tmp_creator)
        tmp_creator = {}

metadata['creators'] = creators

FILE = descriptionfile
description_string = ""
with open(FILE, 'r') as file:
    description_string = file.read().replace('\n', ' ')
示例#8
0
import os
import warnings

# remove all the warnings that show on console
warnings.filterwarnings("ignore")

winning_points = pd.read_csv("data/Winning points.csv")
values = {}
ID = ["a", "b", "c", "d", "e", "f"]
matchname = {}
value = [5]
for we in ID:

    name = filename(we)
    match, matchID, date = (
        name.split("%")[0],
        name.split("%")[1],
        name.split("%")[2][:-4],
    )
    matchname[we] = match
    values[match] = {}
    for k in value:
        players, captain, vc, wkteam, allteam, ballteam, batteam = teams(we, k)
        values[match][k] = None
        teamtotal = 0
        for j in players:
            batscore, ballscore, my11score = 0, 0, 0
            f = ""
            for i in j:
                if i != "(":
                    f += i
示例#9
0
    if ("Contents" not in fileDict["ListBucketResult"]
            or len(fileDict["ListBucketResult"]["Contents"]) == 5):
        break

    # Extract the name date and size from each file
    for i in fileDict["ListBucketResult"]["Contents"]:
        name = i["Key"]
        date = time(i["LastModified"])
        size = int(i["Size"])

        # Keep a running total of the total bucket size
        totalSize += size

        # Running list of files and extentions
        files.append(file(name, size, date))
        mimes.append(name.split(".")[-1].lower())

    print(f"Pulled {len(files)} files     ", end="\r")
    # Hope we don't get rate limited, I'm sure this can be optimised
    if len(files) % 10000 == 0 and len(files):
        print("10s Rate limit sleep", end="\r")
        sleep(10)
    else:
        sleep(1)
    # You request the next page by specifying the last file on the prior page
    pageURL = url + "/?marker=" + files[-1].name

# Convert total bucketsize from bits to GBs
totalSize = round(totalSize / 1000 / 1000 / 1000, 3)
print(f"\n{len(files)} files totaling {totalSize} GB\n")
示例#10
0
 def __init__(self, name, user, url):
     Thread.__init__(self)
     self.password = name.split("\n")[0]
     self.username = user
     self.url = url
     print("-" + self.password + "-")