[Bf-blender-cvs] [b0d9153dd3e] soc-2017-package_manager: Remove commented code and fix some stuff broken by de-addonification
gandalf3
noreply at git.blender.org
Mon Aug 28 09:46:59 CEST 2017
Commit: b0d9153dd3e4f34fafa9fe63694c6fb7636950c1
Author: gandalf3
Date: Sun Aug 27 14:25:17 2017 -0700
Branches: soc-2017-package_manager
https://developer.blender.org/rBb0d9153dd3e4f34fafa9fe63694c6fb7636950c1
Remove commented code and fix some stuff broken by de-addonification
===================================================================
M release/scripts/modules/bpkg/__init__.py
A release/scripts/modules/bpkg/appdirs.py
A release/scripts/modules/bpkg/cache.py
A release/scripts/modules/bpkg/display.py
M release/scripts/modules/bpkg/subproc.py
M release/scripts/startup/bl_operators/package.py
M release/scripts/startup/bl_ui/space_userpref.py
===================================================================
diff --git a/release/scripts/modules/bpkg/__init__.py b/release/scripts/modules/bpkg/__init__.py
index 01fe1a422a2..6a9b50d961a 100644
--- a/release/scripts/modules/bpkg/__init__.py
+++ b/release/scripts/modules/bpkg/__init__.py
@@ -4,48 +4,40 @@
# )
from . import utils
-from .types import (
- Package,
- ConsolidatedPackage,
- Repository,
- )
+from . import types
from pathlib import Path
from collections import OrderedDict
import logging
-import bpy
+tag_reindex = True
packages = {}
-def get_installed_packages(refresh=False) -> list:
- """Get list of packages installed on disk"""
- import addon_utils
- installed_pkgs = []
- for mod in addon_utils.modules(refresh=refresh):
- pkg = Package.from_module(mod)
- pkg.installed = True
- installed_pkgs.append(pkg)
- return installed_pkgs
-
-def get_repo_storage_path() -> Path:
- return Path(bpy.utils.user_resource('CONFIG', 'repositories'))
-
def get_repositories() -> list:
"""
Get list of downloaded repositories and update wm.package_repositories
"""
log = logging.getLogger(__name__ + ".get_repositories")
- storage_path = get_repo_storage_path()
+ import bpy
+ storage_path = Path(bpy.utils.user_resource('CONFIG', 'repositories'))
repos = utils.load_repositories(storage_path)
- log.debug("repos: %s", repos)
-
return repos
-
-def list_packages() -> OrderedDict: # {{{
- """Make an OrderedDict of ConsolidatedPackages from known repositories +
+def _build_packagelist() -> dict: # {{{
+ """Return a dict of ConsolidatedPackages from known repositories and
installed packages, keyed by package name"""
- # log = logging.getLogger(__name__ + ".build_composite_packagelist")
+ log = logging.getLogger(__name__ + "._build_packagelist")
+
+ def get_installed_packages(refresh=False) -> list:
+ """Get list of packages installed on disk"""
+ import addon_utils
+ installed_pkgs = []
+ for mod in addon_utils.modules(refresh=refresh):
+ pkg = types.Package.from_module(mod)
+ pkg.installed = True
+ installed_pkgs.append(pkg)
+ return installed_pkgs
+
masterlist = {}
installed_packages = get_installed_packages(refresh=True)
known_repositories = get_repositories()
@@ -58,14 +50,22 @@ def list_packages() -> OrderedDict: # {{{
if pkg.name in masterlist:
masterlist[pkg.name].add_version(pkg)
else:
- masterlist[pkg.name] = ConsolidatedPackage(pkg)
+ masterlist[pkg.name] = types.ConsolidatedPackage(pkg)
for pkg in installed_packages:
if pkg.name in masterlist:
masterlist[pkg.name].add_version(pkg)
else:
- masterlist[pkg.name] = ConsolidatedPackage(pkg)
+ masterlist[pkg.name] = types.ConsolidatedPackage(pkg)
- # log.debug(masterlist[None].__dict__)
- return OrderedDict(sorted(masterlist.items()))
+ return masterlist
# }}}
+
+
+def list_packages():
+ """Return same dict as _build_packagelist, but only re-build it when tag_reindex == True"""
+ global packages
+ if tag_reindex:
+ packages = _build_packagelist()
+
+ return packages
diff --git a/release/scripts/modules/bpkg/appdirs.py b/release/scripts/modules/bpkg/appdirs.py
new file mode 100644
index 00000000000..13485be7c10
--- /dev/null
+++ b/release/scripts/modules/bpkg/appdirs.py
@@ -0,0 +1,552 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+# Copyright (c) 2005-2010 ActiveState Software Inc.
+# Copyright (c) 2013 Eddy Petrișor
+
+"""Utilities for determining application-specific dirs.
+
+See <http://github.com/ActiveState/appdirs> for details and usage.
+"""
+# Dev Notes:
+# - MSDN on where to store app data files:
+# http://support.microsoft.com/default.aspx?scid=kb;en-us;310294#XSLTH3194121123120121120120
+# - Mac OS X: http://developer.apple.com/documentation/MacOSX/Conceptual/BPFileSystem/index.html
+# - XDG spec for Un*x: http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
+
+__version_info__ = (1, 4, 0)
+__version__ = '.'.join(map(str, __version_info__))
+
+
+import sys
+import os
+
+PY3 = sys.version_info[0] == 3
+
+if PY3:
+ unicode = str
+
+if sys.platform.startswith('java'):
+ import platform
+ os_name = platform.java_ver()[3][0]
+ if os_name.startswith('Windows'): # "Windows XP", "Windows 7", etc.
+ system = 'win32'
+ elif os_name.startswith('Mac'): # "Mac OS X", etc.
+ system = 'darwin'
+ else: # "Linux", "SunOS", "FreeBSD", etc.
+ # Setting this to "linux2" is not ideal, but only Windows or Mac
+ # are actually checked for and the rest of the module expects
+ # *sys.platform* style strings.
+ system = 'linux2'
+else:
+ system = sys.platform
+
+
+
+def user_data_dir(appname=None, appauthor=None, version=None, roaming=False):
+ r"""Return full path to the user-specific data dir for this application.
+
+ "appname" is the name of application.
+ If None, just the system directory is returned.
+ "appauthor" (only used on Windows) is the name of the
+ appauthor or distributing body for this application. Typically
+ it is the owning company name. This falls back to appname. You may
+ pass False to disable it.
+ "version" is an optional version path element to append to the
+ path. You might want to use this if you want multiple versions
+ of your app to be able to run independently. If used, this
+ would typically be "<major>.<minor>".
+ Only applied when appname is present.
+ "roaming" (boolean, default False) can be set True to use the Windows
+ roaming appdata directory. That means that for users on a Windows
+ network setup for roaming profiles, this user data will be
+ sync'd on login. See
+ <http://technet.microsoft.com/en-us/library/cc766489(WS.10).aspx>
+ for a discussion of issues.
+
+ Typical user data directories are:
+ Mac OS X: ~/Library/Application Support/<AppName>
+ Unix: ~/.local/share/<AppName> # or in $XDG_DATA_HOME, if defined
+ Win XP (not roaming): C:\Documents and Settings\<username>\Application Data\<AppAuthor>\<AppName>
+ Win XP (roaming): C:\Documents and Settings\<username>\Local Settings\Application Data\<AppAuthor>\<AppName>
+ Win 7 (not roaming): C:\Users\<username>\AppData\Local\<AppAuthor>\<AppName>
+ Win 7 (roaming): C:\Users\<username>\AppData\Roaming\<AppAuthor>\<AppName>
+
+ For Unix, we follow the XDG spec and support $XDG_DATA_HOME.
+ That means, by default "~/.local/share/<AppName>".
+ """
+ if system == "win32":
+ if appauthor is None:
+ appauthor = appname
+ const = roaming and "CSIDL_APPDATA" or "CSIDL_LOCAL_APPDATA"
+ path = os.path.normpath(_get_win_folder(const))
+ if appname:
+ if appauthor is not False:
+ path = os.path.join(path, appauthor, appname)
+ else:
+ path = os.path.join(path, appname)
+ elif system == 'darwin':
+ path = os.path.expanduser('~/Library/Application Support/')
+ if appname:
+ path = os.path.join(path, appname)
+ else:
+ path = os.getenv('XDG_DATA_HOME', os.path.expanduser("~/.local/share"))
+ if appname:
+ path = os.path.join(path, appname)
+ if appname and version:
+ path = os.path.join(path, version)
+ return path
+
+
+def site_data_dir(appname=None, appauthor=None, version=None, multipath=False):
+ """Return full path to the user-shared data dir for this application.
+
+ "appname" is the name of application.
+ If None, just the system directory is returned.
+ "appauthor" (only used on Windows) is the name of the
+ appauthor or distributing body for this application. Typically
+ it is the owning company name. This falls back to appname. You may
+ pass False to disable it.
+ "version" is an optional version path element to append to the
+ path. You might want to use this if you want multiple versions
+ of your app to be able to run independently. If used, this
+ would typically be "<major>.<minor>".
+ Only applied when appname is present.
+ "multipath" is an optional parameter only applicable to *nix
+ which indicates that the entire list of data dirs should be
+ returned. By default, the first item from XDG_DATA_DIRS is
+ returned, or '/usr/local/share/<AppName>',
+ if XDG_DATA_DIRS is not set
+
+ Typical user data directories are:
+ Mac OS X: /Library/Application Support/<AppName>
+ Unix: /usr/local/share/<AppName> or /usr/share/<AppName>
+ Win XP: C:\Documents and Settings\All Users\Application Data\<AppAuthor>\<AppName>
+ Vista: (Fail! "C:\ProgramData" is a hidden *system* directory on Vista.)
+ Win 7: C:\ProgramData\<AppAuthor>\<AppName> # Hidden, but writeable on Win 7.
+
+ For Unix, this is using the $XDG_DATA_DIRS[0] default.
+
+ WARNING: Do not use this on Windows. See the Vista-Fail note above for why.
+ """
+ if system == "win32":
+ if appauthor is None:
+ appauthor = appname
+ path = os.path.normpath(_get_win_folder("CSIDL_COMMON_APPDATA"))
+ if appname:
+ if appauthor is not False:
+ path = os.path.join(path, appauthor, appname)
+ else:
+ path = os.path.join(path, appname)
+ elif system == 'darwin':
+ path = os.path.expanduser('/Library/Application Support')
+ if appname:
+ path = os.path.join(path, appname)
+ else:
+ # XDG default for $XDG_DATA_DIRS
+ # only first, if multipath is False
+ path = os.getenv('XDG_DATA_DIRS',
+ os.pathsep.join(['/usr/local/share', '/usr/share']))
+ pathlist = [os.path.expandu
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list