files: drop usage of pathlib2, it's now in core python
This commit is contained in:
parent
f9ed4af22a
commit
83b27e53f1
1 changed files with 9 additions and 7 deletions
|
|
@ -25,7 +25,7 @@ import shutil
|
|||
import tempfile
|
||||
import collections
|
||||
import urllib.request, urllib.parse, urllib.error
|
||||
import pathlib2
|
||||
import pathlib
|
||||
|
||||
from pyramid.httpexceptions import HTTPNotFound, HTTPBadRequest, HTTPFound
|
||||
|
||||
|
|
@ -43,7 +43,7 @@ from rhodecode.lib.exceptions import NonRelativePathError
|
|||
from rhodecode.lib.codeblocks import (
|
||||
filenode_as_lines_tokens, filenode_as_annotated_lines_tokens)
|
||||
from rhodecode.lib.utils2 import (
|
||||
convert_line_endings, detect_mode, safe_str, str2bool, safe_int, sha1, safe_unicode)
|
||||
convert_line_endings, detect_mode, safe_str, str2bool, safe_int, sha1)
|
||||
from rhodecode.lib.auth import (
|
||||
LoginRequired, HasRepoPermissionAnyDecorator, CSRFRequired)
|
||||
from rhodecode.lib.vcs import path as vcspath
|
||||
|
|
@ -304,10 +304,10 @@ class RepoFilesView(RepoAppView):
|
|||
def create_pure_path(self, *parts):
|
||||
# Split paths and sanitize them, removing any ../ etc
|
||||
sanitized_path = [
|
||||
x for x in pathlib2.PurePath(*parts).parts
|
||||
x for x in pathlib.PurePath(*parts).parts
|
||||
if x not in ['.', '..']]
|
||||
|
||||
pure_path = pathlib2.PurePath(*sanitized_path)
|
||||
pure_path = pathlib.PurePath(*sanitized_path)
|
||||
return pure_path
|
||||
|
||||
def _is_lf_enabled(self, target_repo):
|
||||
|
|
@ -676,6 +676,7 @@ class RepoFilesView(RepoAppView):
|
|||
# files or dirs
|
||||
try:
|
||||
c.file = c.commit.get_node(f_path)
|
||||
|
||||
c.file_author = True
|
||||
c.file_tree = ''
|
||||
|
||||
|
|
@ -1287,7 +1288,7 @@ class RepoFilesView(RepoAppView):
|
|||
|
||||
root_path = c.file.dir_path
|
||||
pure_path = self.create_pure_path(root_path, filename)
|
||||
node_path = safe_unicode(bytes(pure_path))
|
||||
node_path = pure_path.as_posix()
|
||||
|
||||
default_redirect_url = h.route_path('repo_commit', repo_name=self.db_repo_name,
|
||||
commit_id=commit_id)
|
||||
|
|
@ -1398,6 +1399,7 @@ class RepoFilesView(RepoAppView):
|
|||
message = r_post.get('message') or c.default_message
|
||||
filename = r_post.get('filename')
|
||||
unix_mode = 0
|
||||
|
||||
content = convert_line_endings(r_post.get('content', ''), unix_mode)
|
||||
|
||||
if not filename:
|
||||
|
|
@ -1412,7 +1414,7 @@ class RepoFilesView(RepoAppView):
|
|||
|
||||
root_path = f_path
|
||||
pure_path = self.create_pure_path(root_path, filename)
|
||||
node_path = safe_unicode(bytes(pure_path).lstrip('/'))
|
||||
node_path = pure_path.as_posix().lstrip('/')
|
||||
|
||||
author = self._rhodecode_db_user.full_contact
|
||||
nodes = {
|
||||
|
|
@ -1514,7 +1516,7 @@ class RepoFilesView(RepoAppView):
|
|||
|
||||
root_path = f_path
|
||||
pure_path = self.create_pure_path(root_path, filename)
|
||||
node_path = safe_unicode(bytes(pure_path).lstrip('/'))
|
||||
node_path = pure_path.as_posix().lstrip('/')
|
||||
|
||||
nodes[node_path] = {
|
||||
'content': content
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue