Skip to content

Commit

Permalink
Orgarize template directories
Browse files Browse the repository at this point in the history
  • Loading branch information
huakim authored May 21, 2024
1 parent bb759ba commit 30878d5
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions py2pack/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import platformdirs
import argparse
import datetime
import glob
Expand Down Expand Up @@ -97,13 +97,16 @@ def _get_template_dirs():
"""existing directories where to search for jinja2 templates. The order
is important. The first found template from the first found dir wins!"""
return filter(lambda x: os.path.exists(x), [
os.path.join(i, "templates") for i in (
# user dir
os.path.join(os.path.expanduser('~'), '.py2pack', 'templates'),
# system wide dir
os.path.join('/', 'usr', 'share', 'py2pack', 'templates'),
os.path.join(os.path.expanduser('~'), '.py2pack'),
platformdirs.user_data_dir(appname="py2pack"),
platformdirs.user_config_dir(appname="py2pack"),
# usually inside the site-packages dir
os.path.join(os.path.dirname(os.path.abspath(__file__)), 'templates'),
])
os.path.dirname(os.path.abspath(__file__)),
# system wide dir
*platformdirs.site_data_dir(appname="py2pack", multipath=True).split(":"),
)])


def list_packages(args=None):
Expand Down

0 comments on commit 30878d5

Please sign in to comment.