Skip to main content

一个易于使用、独立于操作系统的游戏/程序更新程序。

项目描述

MBH 更新程序

用于前端文件更新的 Python 脚本。不打算用作后端编程的 GIT 替代品。

概述

这是一个相当简单的程序,可以从网上复制文件并保持文件结构。例如,如果您有/path/to/file/code.txtand /path/to/code.txt,它会将这些文件保存在本地文件夹中。

文档

更新程序类

每个类变量的含义。

class Updater(object):

def __init__(local_version_file="version.txt",
            latest_version_file="new_version.txt",
            latesturl=False, new_files=[],
            new_filesurl=True, output=True,
            source_file="", source_file_enabled=True,
            source_fileurl=True, files_offset=0)
    """
    local_version_file: The downloaded version of the software.
    Should contain a number, like 1, 1.2, 1.234.
    latest_version_file: Likely stored online. This is the latest version of the software.
    Should contain a number, like 2, 2.3, 2.345.
    latesturl: Boolean. Whether or not the file stored at latest_version_file is a url.
    new_files: Array. Contains the location of the files to update if the versions don't match.
    new_filesurl: Boolean. Whether or not the items listed in new_files are urls.
    output: Boolean. Whether or not to write to screen. Ignored for TQDMUpdater.
    source_file: (optional) The location of the source file (where all files required to pull
    are stored).
    source_file_enabled: Boolean. Whether or not to use the source file feature.
    source_fileurl: Whether or not the source file is stored online.
    files_offset: Integer. Contains the folder offset to add to URLs when pulling from online. (eg. If the url is http://files.net/files/source/file.txt, and files_offset is 1, it will be pulled into /source/file.txt. If the offset is 2, it will not be stored in an extra folder.)
    """

初始化更新程序

标准
import mbhupdater.updater

updater = mbhupdater.updater.Updater()
tqdm(进度条)
import mbhupdater.tqdm_updater

updater = mbhupdater.tqdm_updater.TQDMUpdater()

拉取新文件

在不比较版本的情况
updater.pull_files()
下拉取:如果本地版本已过时,则拉取:
updater.compare_and_pull()

当您从在线拉取文件时,您必须在源列表中包含 URLhttp://https://部分 URL,否则从在线拉取文件和在本地写入文件都可能出现错误。

示例源文件

更新程序中有一个可选的源文件功能。如果您正在使用它,这就是您将如何格式化它:

http://www.location1.com/file/file.txt
http://files.server.net/files/code.py
[DELETE]
/local/path/to/file.txt
/local/path/to/file2.txt
/old/thing/file.txt
/old/folder/
/temp/

确保包含在线文件的http://https://,否则它不会输出到正确的文件夹并可能崩溃。
标签下的任何文件[DELETE]都将被删除而不是更新/创建。删除路径必须是本地文件,而不是 URL。
如果你想删除一个文件夹,你必须/在末尾有一个。

获取器和设置器

很容易猜到他们在做什么,他们只是在函数中使用变量名。这是一个列表:

# Getters
get_local_version_file()
get_latest_version_file()
get_latesturl_status()
get_files_offset()
get_new_filesurl_status()
get_output_status()
get_local_version()
get_latest_version()
get_source_file_enabled()
get_source_fileurl_status()
# Setters
set_local_version_file(local_version_file)
set_latest_version_file(latest_version_file)
set_source_file(source_file)
set_files_offset()
toggle_latesturl()
toggle_new_filesurl()
toggle_output()
toggle_source_file_enabled()
toggle_source_fileurl()

所有函数都有将显示在 IDE 中的描述。

其他功能

# Other functions
compare_versions() - Returns True if the versions match and False if the local one is out of date.
read_files()       - Reads the content of the version files. Must use before get_local_version() or get_latest_version()

项目详情


下载文件

下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。

源分布

mbhupdater-0.1.0.tar.gz (6.5 kB 查看哈希

已上传 source

内置分布

mbhupdater-0.1.0-py3-none-any.whl (8.0 kB 查看哈希

已上传 py3