示例#1
0
def clone_scripts(rewrite=False):
    """
    Clone ATF scripts to work directory
    :param rewrite: if True delete atf scripts folder
    """
    clone(config.scripts_repository, config.scripts_clone_dir, config.work_dir,
          branch=config.scripts_branch, rewrite=rewrite)
示例#2
0
def mutate_outside_path(root: list):
    root = clone(root)
    assert len(root) == K

    gens_len = random.randint(1, 2)
    path_id = random.randint(0, K - 1)
    while len(root[path_id]) < gens_len:
        path_id = random.randint(0, K - 1)

    start = random.randint(0, len(root[path_id]) - gens_len)
    gens = root[path_id][start:start + gens_len]

    path_id2 = random.randint(0, K - 1)
    while path_id2 == path_id:
        path_id2 = random.randint(0, K - 1)

    new_candidate = clone(root)
    if (len(new_candidate[path_id2])) == 0:
        index = 0
    else:
        index = random.randint(0, len(new_candidate[path_id2]) - 1)
    new_candidate[path_id2] = new_candidate[path_id2][
        0:index] + gens + new_candidate[path_id2][index:]
    new_candidate[path_id] = root[path_id][0:start] + root[path_id][start +
                                                                    gens_len:]
    return new_candidate
示例#3
0
def clone_atf(rewrite=False):
    """
    Clone ATF to work directory
    :param rewrite: if True delete atf folder
    """
    clone(config.atf_repository, config.atf_build_dir, config.work_dir,
          branch=config.atf_branch, submodules=True, rewrite=rewrite)
示例#4
0
def clone_sdl(rewrite=False):
    """
    Clone SDL to work directory
    :param rewrite: if True delete sdl folder
    """
    clone(config.sdl_repository, config.sdl_clone_dir,
          config.work_dir, branch=config.sdl_branch, rewrite=rewrite)
示例#5
0
 def __init__(self, d_model, num_heads=8):
     super(MultiHeadAttn, self).__init__()
     self.num_heads = num_heads
     d_k = d_v = d_model // self.num_heads
     self.query_projects = clone(nn.Linear(d_model, d_k, bias=False),
                                 n=num_heads)
     self.key_projects = clone(nn.Linear(d_model, d_k, bias=False),
                               n=num_heads)
     self.value_projects = clone(nn.Linear(d_model, d_v, bias=False),
                                 n=num_heads)
     self.out_project = nn.Linear(self.num_heads * d_v, d_model, bias=False)
示例#6
0
 def download(self):
     global app
     path = QFileDialog.getExistingDirectory()
     if path:
         clone("https://github.com/Ryorama/TerrariaCraft-Bedrock", path)
         ok = QMessageBox.information(self, "Success", "Addon was successfully downloaded")
         if ok:
             app.exit(0)
     else:
         ok = QMessageBox.critical(self, "Error", "Download was canceled by user")
         if ok:
             pass
示例#7
0
def mutate_inside_path(root: list):
    root = clone(root)
    assert len(root) == K
    path_id = random.randint(0, K - 1)
    while len(root[path_id]) < 2:
        path_id = random.randint(0, K - 1)
    index = random.randint(0, len(root[path_id]) - 2)

    new_candidate = clone(root)
    cache = new_candidate[path_id][index + 1]
    new_candidate[path_id][index + 1] = new_candidate[path_id][index]
    new_candidate[path_id][index] = cache
    return new_candidate
示例#8
0
def run_docl_bootstrap_or_download():
    ctx.logger.info('Preparing docl bootstrap execution')
    docl_script_path = join(utils.WORKDIR, 'docl_init.sh')
    ctx.download_resource(join('scripts', 'docl_init.sh'), docl_script_path)
    utils.run('chmod +x {0}'.format(docl_script_path))

    ctx.logger.info('Cloning cloudify manager blueprints {0}'
                    .format(MANAGER_BLUEPRINTS_REPO))
    repo_path = utils.clone(**MANAGER_BLUEPRINTS_REPO)

    simple_bp_path = os.path.join(repo_path,
                                  'simple-manager-blueprint.yaml')
    ctx.logger.info('Creating private key file')
    private_key_path = create_key_file()

    rebuild = ctx.node.properties['rebuild']
    if MANAGER_BP_BRANCH != 'master':
        rebuild = 'true'
    utils.run('{0} {1} {2} {3} {4} {5}'
              .format(docl_script_path,
                      utils.CLOUDIFY_VENV_PATH,
                      simple_bp_path,
                      private_key_path,
                      utils.REPOS_DIR,
                      rebuild),
              out=True)
示例#9
0
 def __or__(self, hack):
     """
     >>> a = Hack('a'); b = Hack('b')
     >>> a > 1; b < 2
     >>> c = a | b
     >>> c
     '(a > 1 OR b < 2)'
     >>> d = Hack('d'); e = Hack('e')
     >>> d.set('like', dq('hello%'))
     >>> e.set('in', (1,2,3,4,5))
     >>> d & (e | c)
     'd like "hello%" AND (e in (1, 2, 3, 4, 5) OR (a > 1 OR b < 2))'
     """
     if not isinstance(hack, Hack):
         raise TypeError("unsupported type of %r" % hack.__class__.__name__)
     else:
         se = self.resolve()
         he = hack.resolve()
         sh = tuple(set(se) & set(he))
         if len(sh) > 0:
             raise ValueError("duplicated value %r" % sh[0])
         else:
             cln = clone(self)
             cln._group = '(' + ' OR '.join(i for i in [self.read(), hack.read()] if i != '') + ')'
             return cln
示例#10
0
 def __init__(self, size, self_attn, src_attn, feed_forward, dropout):
     super().__init__()
     self.size = size
     self.self_attn = self_attn
     self.src_attn = src_attn
     self.feed_forward = feed_forward
     self.sublayers = clone(SublayerConnection(size, dropout), 3)
示例#11
0
 def _access_table(self, name):
     try:
         tb = getattr(self.db.tables, name)
     except AttributeError:
         raise ValueError('invalid table name %r' % name)
     else:
         return clone(tb)
示例#12
0
 def __init__(self, h, d_model, dropout=0.1):
     super().__init__()
     assert d_model % h == 0
     self.d_k = d_model // h
     self.h = h
     self.linears = clone(nn.Linear(d_model, d_model), 4)
     self.attn = None
     self.dropout = nn.Dropout(dropout)
示例#13
0
    def __call__(self):
        options, args = self.parser.parse_args(self.gitify.args[2:])

        package_name = basename()
        svntype = svn_type()

        if svntype == 'tags':
            print "Can't work on tags!"
            sys.exit(1)
        elif svntype == 'unrecognized':
            print "Unrecognized svn structure!"
            sys.exit(1)

        if not exists(config.GIT_CACHE + package_name):
            print "No git repository found in %s." % config.GIT_CACHE
            print "Initiating cloning into cache."
            clone()

        # get the branch svn is on
        remote_branch = svn_branch()
        # the following is just convention:
        local_branch = "local/%s" % remote_branch

        cwd = os.getcwd()
        # perform all index updates in the cache to avoid conflicts
        os.chdir(config.GIT_CACHE + package_name)

        dummy, existing_branches = popen('git b', False, False)
        existing_branches = [b.strip() for b in existing_branches]
        if local_branch in existing_branches:
            popen('git checkout -f %s' % local_branch, False, False)
        else:
            popen('git checkout -f -b %s %s' % (local_branch, remote_branch),
                False, False)

        os.chdir(cwd)
        if not exists('.git'):
            popen('ln -s %s%s/.git' % (config.GIT_CACHE, package_name), False, False)

        print "Git branch '%s' is now following svn branch '%s':" % (
            local_branch, remote_branch)
        popen('svn status')
        popen('git status')
示例#14
0
 def field(self, tblname, fieldname):
     try:
         tb = self.tables[tblname]
     except KeyError:
         raise ValueError('invalid table name %r' % tblname)
     else:
         try:
             fd = tb.fields[fieldname]
         except KeyError:
             raise ValueError('invalid field name %r' % fieldname)
         else:
             return clone(fd)
示例#15
0
def test():
    pkgs = path('pkgs').abspath()

    sklearn = ('scikit-learn', 'scikit-learn')
    openalea = ('openalea', 'openalea')

    if not (pkgs / sklearn[-1]).isdir():
        pkgs.cd()
        clone(*sklearn)
        (pkgs / '..').cd()

    if not (pkgs / openalea[-1]).isdir():
        pkgs.cd()
        clone(*openalea)
        (pkgs / '..').cd()

    _tags = tags('pkgs/scikit-learn')
    print _tags

    _versions = list(versions('pkgs/scikit-learn'))
    return _tags, _versions
示例#16
0
def test():
    pkgs = path('pkgs').abspath()
    

    sklearn = ('scikit-learn', 'scikit-learn')
    openalea = ('openalea', 'openalea')

    if not (pkgs/sklearn[-1]).isdir():
        pkgs.cd() 
        clone(*sklearn)
        (pkgs/'..').cd()

    if not (pkgs/openalea[-1]).isdir():
        pkgs.cd() 
        clone(*openalea)
        (pkgs/'..').cd()

    _tags = tags('pkgs/scikit-learn')
    print _tags

    _versions = list(versions('pkgs/scikit-learn'))
    return _tags, _versions
示例#17
0
def install_cloudify_packages():
    utils.create_cloudify_venv()
    ctx.logger.info('Installing cloudify packages...')
    for package in CLOUDIFY_PACKAGES:
        package_path = utils.clone(package_name=package['package_name'],
                                   branch=package['branch'],
                                   org=package['org'])
        if package['package_name'] == 'cloudify-manager':
            utils.pip_install_manager_deps(package_path)
        else:
            utils.pip_install(package_name=package['package_name'],
                              package_path=package_path)

    for package, version in PYTHON_DEPENDENCIES:
        utils.pip_install(package_name=package, version=version)
示例#18
0
def install_cloudify_packages():
    utils.create_cloudify_venv()
    ctx.logger.info('Installing cloudify packages...')
    for package in CLOUDIFY_PACKAGES:
        package_path = utils.clone(package_name=package['package_name'],
                                   branch=package['branch'],
                                   org=package['org'])
        if package['package_name'] == 'cloudify-manager':
            utils.pip_install_manager_deps(package_path)
        else:
            utils.pip_install(package_name=package['package_name'],
                              package_path=package_path)

    for package, version in PYTHON_DEPENDENCIES:
        utils.pip_install(package_name=package,
                          version=version)
示例#19
0
    def equip_item(self, new_item):
        slot = new_item.slot
        old_item = self.get_item_instance(slot)

        text = ""

        new_instance = utils.clone(
            new_item
        )  # We have to clone the item so we don't reference the template.

        self.items[slot] = new_instance
        new_instance.on_equip()

        text += new_instance.get_equip_text() + " "

        if old_item is not None:
            text += old_item.get_replace_text() + " "

        return text
示例#20
0
def load_repos(project):
    # reading in repos
    with open(os.path.join('data', project.name, 'repos.txt')) as f:
        repo_urls = [line.strip() for line in f]

    repos_base = 'gits'
    if not os.path.exists(repos_base):
        utils.mkdir(repos_base)

    repos = list()

    for url in repo_urls:
        repo_name = url.split('/')[-1]
        target = os.path.join(repos_base, repo_name)
        try:
            repo = utils.clone(url, target, bare=True)
        except OSError:
            repo = dulwich.repo.Repo(target)

        repos.append(repo)

    return repos
示例#21
0
def run_docl_bootstrap_or_download():
    ctx.logger.info('Preparing docl bootstrap execution')
    docl_script_path = join(utils.WORKDIR, 'docl_init.sh')
    ctx.download_resource(join('scripts', 'docl_init.sh'), docl_script_path)
    utils.run('chmod +x {0}'.format(docl_script_path))

    ctx.logger.info('Cloning cloudify manager blueprints {0}'.format(
        MANAGER_BLUEPRINTS_REPO))
    repo_path = utils.clone(**MANAGER_BLUEPRINTS_REPO)

    simple_bp_path = os.path.join(repo_path, 'simple-manager-blueprint.yaml')
    ctx.logger.info('Creating private key file')
    private_key_path = create_key_file()

    rebuild = ctx.node.properties['rebuild']
    if MANAGER_BP_BRANCH != 'master':
        rebuild = 'true'
    utils.run('{0} {1} {2} {3} {4} {5}'.format(docl_script_path,
                                               utils.CLOUDIFY_VENV_PATH,
                                               simple_bp_path,
                                               private_key_path,
                                               utils.REPOS_DIR, rebuild),
              out=True)
示例#22
0
 def __and__(self, hack):
     """
     >>> a = Hack('a'); b = Hack('b')
     >>> a > 1; b < 2
     >>> c = a & b
     >>> c
     'a > 1 AND b < 2'
     >>> a
     'a > 1'
     >>> b
     'b < 2'
     """
     if not isinstance(hack, Hack):
         raise TypeError("unsupported type of %r" % hack.__class__.__name__)
     else:
         se = self.resolve()
         he = hack.resolve()
         sh = tuple(set(se) & set(he))
         if len(sh) > 0:
             raise ValueError("duplicated value %r" % sh[0])
         else:
             cln = clone(self)
             cln._group = ' AND '.join(i for i in [self.read(), hack.read()] if i != '')
             return cln
def cloning(constants: Constants, settings: {}, progress: sg.ProgressBar):
    git_dir = utils.install_git(settings["installdir"], constants)
    utils.clone(constants.es_git, settings["installdir"], git_dir)
示例#24
0
def crossover(s1: list, s2: list):
    mother = clone(s1)
    father = clone(s2)
    assert len(mother) == K
    assert len(father) == K

    gens_len = random.randint(1, 3)

    path_id1 = random.randint(0, K - 1)
    while len(mother[path_id1]) < gens_len:
        path_id1 = random.randint(0, K - 1)
    mother_start = random.randint(0, len(mother[path_id1]) - gens_len)

    path_id2 = random.randint(0, K - 1)
    while len(father[path_id2]) < gens_len:
        path_id2 = random.randint(0, K - 1)
    father_start = random.randint(0, len(father[path_id2]) - gens_len)

    mother_gens = mother[path_id1][mother_start:mother_start + gens_len]
    father_gens = father[path_id2][father_start:father_start + gens_len]

    child1 = clone(s1)
    child2 = clone(s2)

    child1[path_id1] = mother[path_id1][0:mother_start] + father_gens + mother[
        path_id1][mother_start + gens_len:]
    child2[path_id2] = father[path_id2][0:father_start] + mother_gens + father[
        path_id2][father_start + gens_len:]

    s = set()
    for i in mother_gens + father_gens:
        if i in mother_gens and i in father_gens:
            s.add(i)

    left = []
    right = []

    for i in mother_gens:
        if i not in s:
            left.append(i)

    for i in father_gens:
        if i not in s:
            right.append(i)
    random.shuffle(left)
    random.shuffle(right)

    mapping_left = {}
    mapping_right = {}
    assert len(left) == len(right)
    for i in range(len(left)):
        mapping_left[right[i]] = left[i]
        mapping_right[left[i]] = right[i]

    for i in range(len(child1)):
        if i == path_id1:
            for j in range(len(child1[i])):
                if j not in range(mother_start, mother_start + gens_len):
                    if child1[i][j] in mapping_left.keys():
                        child1[i][j] = mapping_left[child1[i][j]]
        else:
            for j in range(len(child1[i])):
                if child1[i][j] in mapping_left.keys():
                    child1[i][j] = mapping_left[child1[i][j]]

    for i in range(len(child2)):
        if i == path_id2:
            for j in range(len(child2[i])):
                if j not in range(father_start, father_start + gens_len):
                    if child2[i][j] in mapping_right.keys():
                        child2[i][j] = mapping_right[child2[i][j]]
        else:
            for j in range(len(child2[i])):
                if child2[i][j] in mapping_right.keys():
                    child2[i][j] = mapping_right[child2[i][j]]
    return child1, child2
示例#25
0
    def __init__(self, parent, no_fast=False):
        frame_group = tk.LabelFrame(parent,
                                    text=' 剪片头片尾 ',
                                    padx=2,
                                    pady=4,
                                    width=200)

        self.cb_pt_var1 = tk.IntVar()
        self.cb_pw_var2 = tk.IntVar()
        self.cb_fast_var = tk.IntVar()
        self.cb_mode_var = tk.IntVar()
        cb_pt = tk.Checkbutton(frame_group, variable=self.cb_pt_var1)
        cb_pw = tk.Checkbutton(frame_group, variable=self.cb_pw_var2)

        cb_fast = tk.Checkbutton(frame_group,
                                 text=' 转码-极速模式 ',
                                 variable=self.cb_fast_var,
                                 command=self.cb_fast_call)
        cb_mode = tk.Checkbutton(frame_group,
                                 text=' 修剪-起止模式 ',
                                 variable=self.cb_mode_var,
                                 command=self.cb_mode_call)
        cb_mode.select()
        # cb_pt.select()
        cb_pt.grid(column=1, row=1, sticky=tk.N + tk.S + tk.W)
        cb_pw.grid(column=1, row=2, sticky=tk.N + tk.S + tk.W)
        cb_mode.grid(column=1, row=3, sticky=tk.N + tk.S + tk.W)

        if not no_fast:
            cb_fast.grid(column=1, row=4, sticky=tk.N + tk.S + tk.W)

        pt_input = tk.Text(frame_group,
                           height=1,
                           width=12,
                           fg=theme.COLOR_BLACK,
                           background=theme.COLOR_LIST_BG,
                           wrap=tk.WORD)
        pw_input = utils.clone(pt_input)
        pt_input.grid(column=2, row=1)
        pw_input.grid(column=2, row=2)
        pt_input.insert(tk.INSERT, '6.376')
        pw_input.insert(tk.INSERT, '0')

        pt_label = tk.Label(frame_group,
                            text='秒 这之前的会被剪掉',
                            fg=theme.COLOR_BLACK)
        pw_label = tk.Label(frame_group,
                            text='秒 倒数后的会被剪掉',
                            fg=theme.COLOR_BLACK)
        pt_label.grid(column=3, row=1)
        pw_label.grid(column=3, row=2)

        self.frame = frame_group
        self.pt_input = pt_input
        self.pw_input = pw_input
        self.cb_pt = cb_pt
        self.cb_pw = cb_pw
        self.cb_mode = cb_mode
        self.pt_label = pt_label
        self.pw_label = pw_label

        self.change_mode(True)
示例#26
0
    def __call__(self):
        options, args = self.parser.parse_args(self.gitify.args[2:])

        if not is_svn():
            print "This only works on svn checkouts!"
            sys.exit(1)

        package_name = basename()
        svntype = svn_type()

        if svntype == 'tags':
            print "Can't work on tags!"
            sys.exit(1)
        elif svntype == 'unrecognized':
            print "Unrecognized svn structure!"
            sys.exit(1)

        if not exists(config.GIT_CACHE + package_name):
            print "No git repository found in %s." % config.GIT_CACHE
            print "Initiating cloning into cache."
            clone()
        else:
            # if we already have a cached copy, make sure it's up-to-date:
            print "Updating existing cache:"
            gitify(args=['fetch', package_name])

        # get the branch svn is on
        remote_branch = svn_branch()
        # the following is just convention:
        local_branch = "local/%s" % remote_branch

        cwd = os.getcwd()
        # perform all index updates in the cache to avoid conflicts
        os.chdir(config.GIT_CACHE + package_name)

        dummy, existing_branches = popen('git branch', False, False)
        existing_branches = [b.strip('* ') for b in existing_branches]
        if local_branch in existing_branches:
            popen('git checkout -f %s' % local_branch, False, False)
        else:
            popen('git checkout -f -b %s %s' % (local_branch, remote_branch),
                  False, False)

        os.chdir(cwd)
        if not exists('.git'):
            popen('cp -Rp %s%s/.git .' % (config.GIT_CACHE, package_name),
                  False, False)

        # if the working copy is on another branch, switch:
        if local_branch != git_branch():
            if local_branch in existing_branches:
                popen('git checkout -f %s' % local_branch)
            else:
                popen('git checkout -b %s' % local_branch)

        assert git_branch() == local_branch, (
            "Changing branches failed, is on %r but should be on %r" %
            (git_branch(), local_branch))
        print "Git branch '%s' is now following svn branch '%s':" % (
            local_branch, remote_branch)
        popen('svn status')
        popen('git status')
示例#27
0
 def where(self, hack):
     cln = clone(self)
     cln._where = hack.read()
     return cln
def calculate(f_to_calc, f_to_overwrite, console, download):
    """Calculate a list of features."""

    sys.stdout.write('loading')
    sys.stdout.flush()
    repos = Repo.load_sample()

    seen = 0
    total = len(repos)
    dl_failures = []
    calc_failures = []
    last_write = datetime.datetime.now()

    if f_to_calc or f_to_overwrite or download:
        for repo in repos:
            seen += 1
            success = True

            if download:
                success = utils.clone(repo)

            if not success:
                dl_failures.append(repo)
                continue

            try:
                if f_to_calc:
                    logging.info("calc: %s", repo)
                    repo.calculate_features(f_to_calc)

                if f_to_overwrite:
                    logging.info("calc: %s", repo)
                    repo.calculate_features(f_to_overwrite, overwrite=True)

                repo._clear_support_features()  # we're done with this repo now
            except:
                print  # from status line
                logging.exception("!problem: %s", repo)
                calc_failures.append(repo)
                print

            progress_bar(seen, total)

            since_write = datetime.datetime.now() - last_write

            if since_write > datetime.timedelta(minutes=5):
                sys.stdout.write("\r(writing results)")
                sys.stdout.flush()
                Repo.write_update(repos)

                last_write = datetime.datetime.now()

    print  # from progress bar line

    if dl_failures:
        print "%s failed to download:" % len(dl_failures)
        for f in dl_failures:
            print "  %s" % f
        print

    if calc_failures:
        print "%s failed during calc:" % len(calc_failures)
        for f in calc_failures:
            print "  %s" % f
        print

    if console:
        message = ('`repos` contains results;\n'
                   'use ^d to write out or `exit()` to cancel')
        code.interact(message, local=locals())

    print 'writing out...'
    Repo.write_update(repos)
示例#29
0
 def clone(self):
     return clone(self)
示例#30
0
    def manual_int(self):
        if self.is_manual_int:
            return
        self.is_manual_int = True
        win = self.win

        # 颜色
        GRAP = "#515556"
        LIST_BG = "#EFEFEF"
        LIST_WIDTH = 91 + 10

        frameImport = tk.Frame(win, padx=8, pady=8)
        frame_file = tk.Frame(win, padx=8)
        frameList = tk.Frame(win, padx=8)
        frameOutDir = tk.Frame(win, padx=8)
        frameStart = tk.Frame(win, padx=8)
        frameCB = tk.Frame(win, padx=8)

        frameImport.grid(column=1, row=1, sticky=tk.N + tk.S + tk.W)
        frame_file.grid(column=1, row=2, sticky=tk.N + tk.S + tk.W)
        frameList.grid(column=1, row=3, sticky=tk.N + tk.S + tk.W)
        frameOutDir.grid(column=1, row=4, sticky=tk.N + tk.S + tk.W)
        frameCB.grid(column=1, row=5, sticky=tk.N + tk.S + tk.W)
        frameStart.grid(column=1, row=6, sticky=tk.N + tk.S + tk.W)

        self.importBtn = tk.Button(frameImport, text='导入文件', width=14)
        self.importBtn.bind("<Button-1>", self.importCall)
        self.importBtn.grid(column=1, row=0)

        self.smartNotice = " ;-) 点我 粘贴视频文件"
        self.smartPaste = tk.Text(frameImport, height=1, width=LIST_WIDTH - 22, fg=GRAP, wrap=tk.WORD,
                                  font=setting_fftool.font_default)
        self.smartPaste.grid(column=2, row=0)
        self.smartPaste.bind("<Leave>", self.smartPasteLeave)
        self.smartPaste.bind("<Button-1>", self.smartPasteClick)
        self.smartPaste.insert(tk.INSERT, self.smartNotice)

        # tk.Label(frameImport, height=1, width=LIST_WIDTH-22).grid(column=2, row=0)   # 右边距

        self.randomBtn = tk.Button(frameImport, text='⇌随机', width=9)
        self.randomBtn.bind("<Button-1>", self.randomCall)
        self.randomBtn.grid(column=6, row=0)

        self.varL = tk.StringVar()
        self.varC = tk.StringVar()
        self.varR = tk.StringVar()
        self.listL = tk.Listbox(
            frameList,
            selectmode=tk.EXTENDED,
            fg=GRAP,
            background=LIST_BG,
            height=20,
            setgrid=1,
            activestyle='none')
        self.listC = utils.clone(self.listL)
        self.listR = utils.clone(self.listL)
        self.listL.config(yscrollcommand=self.yscrollL, listvariable=self.varL, bd=1, justify=tk.LEFT, width=48 - 2)
        self.listC.config(yscrollcommand=self.yscrollC, listvariable=self.varC, bd=0, justify=tk.CENTER, width=7)
        self.listR.config(yscrollcommand=self.yscrollR, listvariable=self.varR, bd=1, justify=tk.LEFT, width=48 - 2)
        self.listL.grid(column=1, row=10, sticky=tk.E)
        self.listC.grid(column=2, row=10, sticky=tk.W)
        self.listR.grid(column=3, row=10, sticky=tk.W)

        self.scrollbar = tk.Scrollbar(frameList, orient='vertical', command=self.yview)
        self.scrollbar.grid(column=4, row=10, sticky=tk.N + tk.S + tk.W)

        self.fc_out = FileChooser(frameOutDir, btn_text=" 输出目录 ", action_btn_text='选择目录', btn_call=self.gotoOutDir,
                                  isFolder=True, hasGROOVE=True, text_width=84)
        frame_out = self.fc_out.get_frame()
        frame_out.grid(column=1, row=21, sticky=tk.NW)

        self.CheckVar1 = tk.IntVar()
        self.cb1 = tk.Checkbutton(frameCB, text="极速模式", variable=self.CheckVar1)
        self.cb1.grid(column=1, row=1, sticky=tk.W)

        # 开始转码 按钮
        self.start_btn = Start(frameStart, text='开始\n合并', command=self.startCheck)
        self.start_btn.grid(column=1, row=1, sticky=tk.W)
        self.start_btn.set_state(False)
        tup = (self.importBtn, self.randomBtn, self.listL, self.listR)
        utils.set_groove(tup)

        self.autoSelect()
示例#31
0
    def manual_int(self):
        if self.is_manual_int:
            return
        self.is_manual_int = True
        win = self.win
        self.hasQuery = False
        self.LeftIsReverse = False
        self.RightIsReverse = False
        self.sortDesc = ('排序↕', "升序a-z", '降序z-a')
        """组装 ui
        """
        # 颜色
        GRAP = "#515556"
        # GRAP2 = "#B9BFC1"
        # TXT_BG = "#ECECEC"
        LIST_BG = "#EFEFEF"
        LIST_WIDTH = 91 + 10
        # TXT_WIDTH = 80+7
        # FILE_GAP = 65+10
        # WRAP_LENGTH = 780

        frame = tk.Frame(win, padx=8, pady=2)
        frame.grid(column=1, row=0, sticky=tk.N + tk.S + tk.W)

        self.svL = StringVar()
        self.svC = StringVar()
        self.svR = StringVar()
        varL = self.svL.get_object()
        varC = self.svC.get_object()
        varR = self.svR.get_object()
        self.list_l = tk.Listbox(frame,
                                 selectmode=tk.EXTENDED,
                                 fg=GRAP,
                                 background=LIST_BG,
                                 height=20,
                                 setgrid=1,
                                 activestyle='none')
        self.list_c = utils.clone(self.list_l)
        self.list_r = utils.clone(self.list_l)
        self.list_l.config(yscrollcommand=self.yscroll1, listvariable=varL)
        self.list_c.config(yscrollcommand=self.yscroll2, listvariable=varC)
        self.list_r.config(yscrollcommand=self.yscroll3, listvariable=varR)
        self.list_l.config(bd=1, justify=tk.RIGHT, width=LIST_WIDTH - 35)
        self.list_c.config(bd=0, justify=tk.CENTER, width=7)
        self.list_r.config(bd=1, justify=tk.LEFT, width=25)
        self.list_l.grid(column=1, row=10, sticky=tk.E)
        self.list_c.grid(column=2, row=10, sticky=tk.W)
        self.list_r.grid(column=3, row=10, sticky=tk.W)

        self.scrollbar = tk.Scrollbar(frame,
                                      orient='vertical',
                                      command=self.yview)
        self.scrollbar.grid(column=4, row=10, sticky=tk.N + tk.S + tk.W)

        # test
        # for x in range(30):
        #     self.list_l.insert('end', x)
        #     self.list_r.insert('end', x)

        self.msgLeft = " ;-) 点我 粘贴 需命名的文件"
        self.paste_l = tk.Text(frame,
                               height=1,
                               width=LIST_WIDTH - 30,
                               fg=GRAP,
                               wrap=tk.WORD,
                               font=setting_fftool.font_default)
        self.paste_l.bind("<Leave>", self.paste_leave_left)
        self.paste_l.bind("<Button-1>", self.pasteClick)
        self.paste_l.tag_config("right", justify=tk.RIGHT)
        self.paste_l.insert(tk.INSERT, self.msgLeft, "right")

        self.msg_right = " ;-) 粘贴 文件名 或 文件"
        self.paste_r = tk.Text(frame,
                               height=1,
                               width=25,
                               fg=GRAP,
                               wrap=tk.WORD,
                               font=setting_fftool.font_default)
        self.paste_r.bind("<Leave>", self.leave_right)
        self.paste_r.bind("<Button-1>", self.pasteClick)
        self.paste_r.insert(tk.INSERT, self.msg_right)

        self.paste_l.grid(column=1, row=0, sticky=tk.NE)
        self.paste_r.grid(column=3, row=0, sticky=tk.NW)

        # 左右排序按钮
        fleft = tk.Frame(frame, padx=8, pady=2)
        fRight = tk.Frame(frame, padx=8, pady=2)

        desc = self.sortDesc
        self.sortLS = tk.Button(fleft, text=desc[0], width=7)
        self.sortLU = tk.Button(fleft, text='↑', width=2)
        self.sortLD = tk.Button(fleft, text='↓', width=2)

        self.sortRS = tk.Button(fRight, text=desc[0], width=7)
        self.sortRU = tk.Button(fRight, text='↑', width=2)
        self.sortRD = tk.Button(fRight, text='↓', width=2)

        widgets = (self.sortLS, self.sortLU, self.sortLD, self.sortRS,
                   self.sortRU, self.sortRD)
        for w in widgets:
            utils.bind(w, self.sortCall)

        fleft.grid(column=1, row=5, sticky=tk.NE)
        self.sortLS.grid(column=4, row=1)
        self.sortLU.grid(column=2, row=1)
        self.sortLD.grid(column=3, row=1)

        fRight.grid(column=3, row=5, sticky=tk.NE)
        self.sortRS.grid(column=1, row=1)
        self.sortRU.grid(column=2, row=1)
        self.sortRD.grid(column=3, row=1)
        start_btn = tk.Button(frame,
                              text='开始\n命名',
                              width=6,
                              height=3,
                              command=self.start_check,
                              relief=tk.GROOVE)
        undo_btn = tk.Button(frame,
                             text='↺撤销',
                             width=6,
                             height=1,
                             command=self.start_check,
                             relief=tk.GROOVE)
        start_btn.grid(column=2, row=20)
        undo_btn.grid(column=2, row=21)
        utils.set_state(start_btn, False)
        utils.set_state(undo_btn, False)

        # 统一设置样式
        tub1 = (self.list_l, self.list_r, start_btn, undo_btn)
        tub = widgets + tub1
        utils.set_groove(tub)

        self.undo_btn = undo_btn
        self.start_btn = start_btn
示例#32
0
 def __init__(self, layer, N):
     super().__init__()
     self.layers = clone(layer, N)
     self.norm = LayerNorm(layer.size)
示例#33
0
from utils import clone
import os


if __name__ == '__main__':
    print("Downloading to:", os.getcwd())
    clone("https://github.com/Ryorama/TerrariaCraft-Bedrock")
    print("\nSuccessfully downloaded")