GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — python-for-android/pythonforandroid/patching.py at develop · kivy/python-for-android Expand file tree/ Copy pathpatching.pyMore file actions 178 lines (110 loc) · 3.66 KB / Copy pathpatching.pyFile metadata and controls178 lines (110 loc) · 3.66 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 """ Helper functions for recipes. Recipes must supply a list of patches. Patches consist of a filename and an optional conditional, which is any function of the form: def patch_check(arch: string, recipe : Recipe) -> bool This library provides some helpful conditionals and mechanisms to join multiple conditionals. Example: patches = [ ("linux_or_darwin_only.patch", check_any(is_linux, is_darwin), ("recent_android_API.patch", is_apt_gte(27)), ] """ from platform import uname from packaging.version import Version # Platform checks def is_platform(platform): """ Returns true if the host platform matches the parameter given. """ def check(arch, recipe): return uname().system.lower() == platform.lower() return check is_linux = is_platform("Linux") is_darwin = is_platform("Darwin") is_windows = is_platform("Windows") def is_arch(xarch): """ Returns true if the target architecture platform matches the parameter given. """ def check(arch): return arch.arch == xarch return check # Android API comparisons: # Return true if the Android API level being targeted # is equal (or >, >=, <, <= as appropriate) the given parameter def is_api(apiver: int): def check(arch, recipe): return recipe.ctx.android_api == apiver return check def is_api_gt(apiver: int): def check(arch, recipe): return recipe.ctx.android_api > apiver return check def is_api_gte(apiver: int): def check(arch, recipe): return recipe.ctx.android_api >= apiver return check def is_api_lt(apiver: int): def check(arch, recipe): return recipe.ctx.android_api < apiver return check def is_api_lte(apiver: int): def check(arch, recipe): return recipe.ctx.android_api <= apiver return check # Android API comparisons: def is_ndk(ndk): """ Return true if the Minimum Supported Android NDK level being targeted is equal the given parameter (which should be an AndroidNDK instance) """ def check(arch, recipe): return recipe.ctx.ndk == ndk return check # Recipe Version comparisons: # These compare the Recipe's version with the provided string (or # Packaging.Version). # # Warning: Both strings must conform to PEP 440 - e.g. "3.2.1" or "1.0rc1" def is_version_gt(version): """Return true if the Recipe's version is greater""" def check(arch, recipe): return Version(recipe.version) > Version(version) return check def is_version_lt(version): """Return true if the Recipe's version is less than""" def check(arch, recipe): return Version(recipe.version) < Version(version) return check def version_starts_with(version_prefix): def check(arch, recipe): return recipe.version.startswith(version_prefix) return check # Will Build def will_build(recipe_name): """Return true if the recipe with this name is planned to be included in the distribution.""" def check(arch, recipe): return recipe_name in recipe.ctx.recipe_build_order return check # Conjunctions def check_all(*patch_checks): """ Given a collection of patch_checks as params, return if all returned true. """ def check(arch, recipe): return all(patch_check(arch, recipe) for patch_check in patch_checks) return check def check_any(*patch_checks): """ Given a collection of patch_checks as params, return if any returned true. """ def check(arch, recipe): return any(patch_check(arch, recipe) for patch_check in patch_checks) return check |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |