Пример #1
0
    def __init__(self, pack):
        for i, line in enumerate(pack.lines):
            try:
                pattern = 'import (.*) from (.*)'
                res = re.findall(pattern, line)
                if len(res) > 0:
                    pack.lines[i] = ''
                    continue

                if line.startswith('export'):
                    pack.lines[i] = ''
                    continue

                pattern = '[\'|\"](.*\.js)[\'|\"]'
                res = re.findall(pattern, line)
                if len(res) <= 0:
                    continue

                s = res[0]

                if s.startswith('http'):
                    continue

                for a in range(30):
                    js_path = pack.watch_file_dir + '../' * a + s
                    if OS.is_file(js_path):
                        break

                ctime = str(os.path.getmtime(js_path))
                pack.require_js.add(os.path.abspath(js_path))
                pack.lines[i] = re.sub('[\'|\"].*\.js[\'|\"]', '"' + s + '?v=' + ctime + '"', line)
            except:
                pack.lines[i] = line
Пример #2
0
    def __init__(self, task):
        self.watch_file = task['file_dir'] + task['file_name']
        self.watch_file_dir = task['file_dir']
        if not OS.is_file(self.watch_file):  # 删除操作
            exit()

        f = OS.open(self.watch_file)
        self.lines = f.readlines(99999)
        f.close()
        self.host = task['upload_host']  # 主机
        self.port = task['upload_port']  # 端口
        self.username = task['upload_user']  # 用户名
        self.password = task['upload_pwd']  # 密码
        self.upload_root = task['upload_root']  # 密码
        self.root = task['root']  # 密码