Skip to content

Commit

Permalink
fix #8 - windows support.
Browse files Browse the repository at this point in the history
  • Loading branch information
jensens committed Aug 10, 2020
1 parent ebec5fd commit 0c579e7
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/z3c/jbot/manager.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import os
import sys
import tempfile

from zope.interface import implementer

from . import interfaces
from . import utility


IGNORE = object()
DELETE = object()



def root_length(a, b):
if b.startswith(a):
return len(a)
Expand Down Expand Up @@ -40,12 +43,13 @@ def find_zope2_product(path):

def find_package(syspaths, path):
"""Determine the Python-package where path is located. If the path is
not located within the Python sys-path, return ``None``."""
not located within the Python sys-path, return ``None``.
The returned path is already 'normcase'. """

_syspaths = sort_by_path(path, syspaths)
syspath = _syspaths[0]
syspath = os.path.normcase(os.path.normpath(_syspaths[0]))

path = os.path.normpath(path)
path = os.path.normcase(os.path.normpath(path))
if not path.startswith(syspath):
if utility.ZOPE_2:
return find_zope2_product(path)
Expand Down Expand Up @@ -78,16 +82,19 @@ def __init__(self, name):
self.name = name

def registerDirectory(self, directory):
directory = os.path.normcase(directory)
self.directories.add(directory)

for filename in os.listdir(directory):
filename = os.path.normcase(filename)
self.paths[filename] = "%s/%s" % (directory, filename)

for template, filename in list(self.templates.items()):
if filename is IGNORE:
del self.templates[template]

def unregisterDirectory(self, directory):
directory = os.path.normcase(directory)
self.directories.remove(directory)

templates = []
Expand Down Expand Up @@ -122,7 +129,7 @@ def registerTemplate(self, template, token):

# verify that override has not been unregistered
if filename is not None and filename not in paths:
template.filename = template._filename
template.filename = os.path.normcase(template._filename)
del self.templates[token]

# check if an override exists
Expand All @@ -132,7 +139,7 @@ def registerTemplate(self, template, token):
self.templates[token] = IGNORE
return

filename = path.replace(os.path.sep, '.')
filename = path.replace('/', '.')
if filename not in paths:
self.templates[token] = IGNORE
template._v_last_read = False
Expand Down

0 comments on commit 0c579e7

Please sign in to comment.