|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2020 - 2021 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 |
|
7 """ |
|
8 Module implementing message translations for the code style plugin messages |
|
9 (pathlib part). |
|
10 """ |
|
11 |
|
12 from PyQt5.QtCore import QCoreApplication |
|
13 |
|
14 _pathlibMessages = { |
|
15 "P101": QCoreApplication.translate( |
|
16 "PathlibChecker", |
|
17 "os.chmod('foo', 0o444) should be replaced by foo_path.chmod(0o444)"), |
|
18 "P102": QCoreApplication.translate( |
|
19 "PathlibChecker", |
|
20 "os.mkdir('foo') should be replaced by foo_path.mkdir()"), |
|
21 "P103": QCoreApplication.translate( |
|
22 "PathlibChecker", |
|
23 "os.makedirs('foo/bar') should be replaced by " |
|
24 "bar_path.mkdir(parents=True)"), |
|
25 "P104": QCoreApplication.translate( |
|
26 "PathlibChecker", |
|
27 "os.rename('foo', 'bar') should be replaced by " |
|
28 "foo_path.rename(Path('bar'))"), |
|
29 "P105": QCoreApplication.translate( |
|
30 "PathlibChecker", |
|
31 "os.replace('foo', 'bar') should be replaced by " |
|
32 "foo_path.replace(Path('bar'))"), |
|
33 "P106": QCoreApplication.translate( |
|
34 "PathlibChecker", |
|
35 "os.rmdir('foo') should be replaced by foo_path.rmdir()"), |
|
36 "P107": QCoreApplication.translate( |
|
37 "PathlibChecker", |
|
38 "os.remove('foo') should be replaced by foo_path.unlink()"), |
|
39 "P108": QCoreApplication.translate( |
|
40 "PathlibChecker", |
|
41 "os.unlink('foo'') should be replaced by foo_path.unlink()"), |
|
42 "P109": QCoreApplication.translate( |
|
43 "PathlibChecker", |
|
44 "os.getcwd() should be replaced by Path.cwd()"), |
|
45 "P110": QCoreApplication.translate( |
|
46 "PathlibChecker", |
|
47 "os.readlink('foo') should be replaced by foo_path.readlink()"), |
|
48 "P111": QCoreApplication.translate( |
|
49 "PathlibChecker", |
|
50 "os.stat('foo') should be replaced by foo_path.stat() or " |
|
51 "foo_path.owner() or foo_path.group()"), |
|
52 |
|
53 "P201": QCoreApplication.translate( |
|
54 "PathlibChecker", |
|
55 "os.path.abspath('foo') should be replaced by foo_path.resolve()"), |
|
56 "P202": QCoreApplication.translate( |
|
57 "PathlibChecker", |
|
58 "os.path.exists('foo') should be replaced by foo_path.exists()"), |
|
59 "P203": QCoreApplication.translate( |
|
60 "PathlibChecker", |
|
61 "os.path.expanduser('~/foo') should be replaced by " |
|
62 "foo_path.expanduser()"), |
|
63 "P204": QCoreApplication.translate( |
|
64 "PathlibChecker", |
|
65 "os.path.isdir('foo') should be replaced by foo_path.is_dir()"), |
|
66 "P205": QCoreApplication.translate( |
|
67 "PathlibChecker", |
|
68 "os.path.isfile('foo') should be replaced by foo_path.is_file()"), |
|
69 "P206": QCoreApplication.translate( |
|
70 "PathlibChecker", |
|
71 "os.path.islink('foo') should be replaced by foo_path.is_symlink()"), |
|
72 "P207": QCoreApplication.translate( |
|
73 "PathlibChecker", |
|
74 "os.path.isabs('foo') should be replaced by foo_path.is_absolute()"), |
|
75 "P208": QCoreApplication.translate( |
|
76 "PathlibChecker", |
|
77 "os.path.join('foo', 'bar') should be replaced by " |
|
78 "foo_path / 'bar'"), |
|
79 "P209": QCoreApplication.translate( |
|
80 "PathlibChecker", |
|
81 "os.path.basename('foo/bar') should be replaced by bar_path.name"), |
|
82 "P210": QCoreApplication.translate( |
|
83 "PathlibChecker", |
|
84 "os.path.dirname('foo/bar') should be replaced by bar_path.parent"), |
|
85 "P211": QCoreApplication.translate( |
|
86 "PathlibChecker", |
|
87 "os.path.samefile('foo', 'bar') should be replaced by " |
|
88 "foo_path.samefile(bar_path)"), |
|
89 "P212": QCoreApplication.translate( |
|
90 "PathlibChecker", |
|
91 "os.path.splitext('foo.bar') should be replaced by foo_path.suffix"), |
|
92 |
|
93 "P301": QCoreApplication.translate( |
|
94 "PathlibChecker", |
|
95 "open('foo') should be replaced by Path('foo').open()"), |
|
96 |
|
97 "P401": QCoreApplication.translate( |
|
98 "PathlibChecker", |
|
99 "py.path.local is in maintenance mode, use pathlib instead"), |
|
100 } |