Skip to content

Commit 9cff27e

Browse files
committed
lint
1 parent 0e4201d commit 9cff27e

File tree

2 files changed

+12
-49
lines changed

2 files changed

+12
-49
lines changed

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
include LICENSE
22
include README.md
3+
include requirements.txt
34
include npm_mjs/package.json
45
include npm_mjs/templates/npm_mjs/static_urls_js.html
56
include npm_mjs/management/commands/webpack.config.template.js

npm_mjs/management/commands/makemessages.py

Lines changed: 11 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,17 @@
22
import re
33
import shutil
44
import tempfile
5-
import urllib
65

76
from base.management import BaseCommand
8-
from django.core.management import call_command
97
from django.core.management.commands import makemessages
10-
from django.core.management.utils import popen_wrapper
11-
from django.utils.translation import templatize
128
from django.utils.functional import cached_property
13-
from django.utils.jslex import JsLexer, Tok
14-
JsLexer.both_before.append(Tok("template", r"`([^\\]|(\\(.|\n)))*?`", next="div"),)
9+
from django.utils.jslex import JsLexer
10+
from django.utils.jslex import Tok
11+
from django.utils.translation import templatize
12+
13+
JsLexer.both_before.append(
14+
Tok("template", r"`([^\\]|(\\(.|\n)))*?`", next="div"),
15+
)
1516

1617
# This makes makemessages create both translations for Python and JavaScript
1718
# code in one go.
@@ -54,12 +55,12 @@ def escape_quotes(m):
5455
tok = '"' + guts + '"'
5556
elif name == "template":
5657
# Split the template string into chunks using the ${...} pattern
57-
chunks = re.findall(r'\${(.*?)}', tok)
58+
chunks = re.findall(r"\${(.*?)}", tok)
5859
# Concatenate the chunks with "+"
5960
for chunk in chunks:
60-
tok = tok.replace('${' + chunk + '}', '" + ' + chunk + ' + "', 1)
61+
tok = tok.replace("${" + chunk + "}", '" + ' + chunk + ' + "', 1)
6162
# Replace backtick-quotes with double-quotes.
62-
tok = '"' + tok[1:-1] +'"'
63+
tok = '"' + tok[1:-1] + '"'
6364
elif name == "id":
6465
# C can't deal with Unicode escapes in identifiers. We don't
6566
# need them for gettext anyway, so replace them with something
@@ -70,7 +71,6 @@ def escape_quotes(m):
7071

7172

7273
class BuildFile(makemessages.BuildFile):
73-
7474
@cached_property
7575
def is_templatized(self):
7676
if self.domain == "djangojs":
@@ -101,11 +101,11 @@ def preprocess(self):
101101
def cleanup(self):
102102
pass
103103

104+
104105
class Command(makemessages.Command, BaseCommand):
105106
build_file_class = BuildFile
106107

107108
def handle(self, *args, **options):
108-
#call_command("transpile")
109109
options["ignore_patterns"] += [
110110
"venv",
111111
".direnv",
@@ -120,41 +120,3 @@ def handle(self, *args, **options):
120120
super().handle(*args, **options)
121121
shutil.rmtree(self.temp_dir_in)
122122
shutil.rmtree(self.temp_dir_out)
123-
124-
# def process_locale_dir(self, locale_dir, files):
125-
# if self.domain == "djangojs":
126-
# for file in files:
127-
# # We need to copy the JS files first, as otherwise babel will
128-
# # attempt to read package.json files in subdirs, such as
129-
# # base/package.json
130-
# in_path = urllib.parse.urljoin(self.temp_dir_in + "/", file.dirpath)
131-
# os.makedirs(in_path, exist_ok=True)
132-
# in_file = urllib.parse.urljoin(in_path + "/", file.file)
133-
# shutil.copy2(file.path, in_file)
134-
# out_path = urllib.parse.urljoin(self.temp_dir_out + "/", file.dirpath)
135-
# file.dirpath = out_path
136-
# os.chdir(".transpile/")
137-
# out, err, status = popen_wrapper(
138-
# [
139-
# "npm",
140-
# "run",
141-
# "babel-transform-template-literals",
142-
# "--",
143-
# "--out-dir",
144-
# self.temp_dir_out,
145-
# self.temp_dir_in,
146-
# ],
147-
# )
148-
# os.chdir("../")
149-
#
150-
# super().process_locale_dir(locale_dir, files)
151-
#
152-
# def write_po_file(self, potfile, locale):
153-
# if self.domain == "djangojs":
154-
# with open(potfile, encoding="utf-8") as fp:
155-
# msgs = fp.read()
156-
# # Remove temp dir path info
157-
# msgs = msgs.replace(self.temp_dir_out + "/", "")
158-
# with open(potfile, "w", encoding="utf-8") as fp:
159-
# fp.write(msgs)
160-
# super().write_po_file(potfile, locale)

0 commit comments

Comments
 (0)