Browse Source

增加批量更新js错误

liuyuqi-dellpc 6 years ago
parent
commit
a5c056ac76
10 changed files with 262 additions and 0 deletions
  1. 20 0
      .classpath
  2. 3 0
      .gitignore
  3. 23 0
      .project
  4. 100 0
      .vscode/.ropeproject/config.py
  5. BIN
      .vscode/.ropeproject/objectdb
  6. 12 0
      README.md
  7. 50 0
      js_convert.py
  8. 22 0
      pom.xml
  9. 11 0
      src/me/yoqi/Utils/FileUtils.java
  10. 21 0
      src/me/yoqi/fix/Main.java

+ 20 - 0
.classpath

@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" output="target/classes" path="src">
+		<attributes>
+			<attribute name="optional" value="true"/>
+			<attribute name="maven.pomderived" value="true"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5">
+		<attributes>
+			<attribute name="maven.pomderived" value="true"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
+		<attributes>
+			<attribute name="maven.pomderived" value="true"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry kind="output" path="target/classes"/>
+</classpath>

+ 3 - 0
.gitignore

@@ -6,3 +6,6 @@ vendor/
 # You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
 # composer.lock
 
+/bin/
+/target/
+/.settings

+ 23 - 0
.project

@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>fix-teleport</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.m2e.core.maven2Builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.m2e.core.maven2Nature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>

+ 100 - 0
.vscode/.ropeproject/config.py

@@ -0,0 +1,100 @@
+# The default ``config.py``
+# flake8: noqa
+
+
+def set_prefs(prefs):
+    """This function is called before opening the project"""
+
+    # Specify which files and folders to ignore in the project.
+    # Changes to ignored resources are not added to the history and
+    # VCSs.  Also they are not returned in `Project.get_files()`.
+    # Note that ``?`` and ``*`` match all characters but slashes.
+    # '*.pyc': matches 'test.pyc' and 'pkg/test.pyc'
+    # 'mod*.pyc': matches 'test/mod1.pyc' but not 'mod/1.pyc'
+    # '.svn': matches 'pkg/.svn' and all of its children
+    # 'build/*.o': matches 'build/lib.o' but not 'build/sub/lib.o'
+    # 'build//*.o': matches 'build/lib.o' and 'build/sub/lib.o'
+    prefs['ignored_resources'] = ['*.pyc', '*~', '.ropeproject',
+                                  '.hg', '.svn', '_svn', '.git', '.tox']
+
+    # Specifies which files should be considered python files.  It is
+    # useful when you have scripts inside your project.  Only files
+    # ending with ``.py`` are considered to be python files by
+    # default.
+    #prefs['python_files'] = ['*.py']
+
+    # Custom source folders:  By default rope searches the project
+    # for finding source folders (folders that should be searched
+    # for finding modules).  You can add paths to that list.  Note
+    # that rope guesses project source folders correctly most of the
+    # time; use this if you have any problems.
+    # The folders should be relative to project root and use '/' for
+    # separating folders regardless of the platform rope is running on.
+    # 'src/my_source_folder' for instance.
+    #prefs.add('source_folders', 'src')
+
+    # You can extend python path for looking up modules
+    #prefs.add('python_path', '~/python/')
+
+    # Should rope save object information or not.
+    prefs['save_objectdb'] = True
+    prefs['compress_objectdb'] = False
+
+    # If `True`, rope analyzes each module when it is being saved.
+    prefs['automatic_soa'] = True
+    # The depth of calls to follow in static object analysis
+    prefs['soa_followed_calls'] = 0
+
+    # If `False` when running modules or unit tests "dynamic object
+    # analysis" is turned off.  This makes them much faster.
+    prefs['perform_doa'] = True
+
+    # Rope can check the validity of its object DB when running.
+    prefs['validate_objectdb'] = True
+
+    # How many undos to hold?
+    prefs['max_history_items'] = 32
+
+    # Shows whether to save history across sessions.
+    prefs['save_history'] = True
+    prefs['compress_history'] = False
+
+    # Set the number spaces used for indenting.  According to
+    # :PEP:`8`, it is best to use 4 spaces.  Since most of rope's
+    # unit-tests use 4 spaces it is more reliable, too.
+    prefs['indent_size'] = 4
+
+    # Builtin and c-extension modules that are allowed to be imported
+    # and inspected by rope.
+    prefs['extension_modules'] = []
+
+    # Add all standard c-extensions to extension_modules list.
+    prefs['import_dynload_stdmods'] = True
+
+    # If `True` modules with syntax errors are considered to be empty.
+    # The default value is `False`; When `False` syntax errors raise
+    # `rope.base.exceptions.ModuleSyntaxError` exception.
+    prefs['ignore_syntax_errors'] = False
+
+    # If `True`, rope ignores unresolvable imports.  Otherwise, they
+    # appear in the importing namespace.
+    prefs['ignore_bad_imports'] = False
+
+    # If `True`, rope will insert new module imports as
+    # `from <package> import <module>` by default.
+    prefs['prefer_module_from_imports'] = False
+
+    # If `True`, rope will transform a comma list of imports into
+    # multiple separate import statements when organizing
+    # imports.
+    prefs['split_imports'] = False
+
+    # If `True`, rope will sort imports alphabetically by module name
+    # instead of alphabetically by import statement, with from imports
+    # after normal imports.
+    prefs['sort_imports_alphabetically'] = False
+
+
+def project_opened(project):
+    """This function is called after opening the project"""
+    # Do whatever you like here!

BIN
.vscode/.ropeproject/objectdb


+ 12 - 0
README.md

@@ -16,3 +16,15 @@
 中文乱码,使用工具:
 
 [http://others.yoqi.me/convert.php](http://others.yoqi.me/convert.php)
+
+##20171223更新
+1. 由于普通正则表达式无法对正则表达式内继续正则匹配。增加js_convert.py,对项目中文件
+href="javascript:if(confirm(%27http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=31011502004838  \n\nThis file was not retrie
+ved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address.  \n\nDo you want t
+o open it from the server?%27))window.location=%27http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=31011502004838%27"
+
+批量更改为:
+
+href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=31011502004838"
+
+2. java项目批量正则修改就不需要继续开发了。

+ 50 - 0
js_convert.py

@@ -0,0 +1,50 @@
+import os
+import chardet
+import codecs
+import re
+
+
+def WriteFile(filePath, u, encoding="utf-8"):
+    with codecs.open(filePath, "w", encoding) as f:
+        print(filePath)
+        f.write(u)
+
+
+def convert(src, dst):
+    #     检测编码,coding可能检测不到编码,有异常
+    f = open(src, "rb")
+    coding = chardet.detect(f.read())["encoding"]
+    f.close()
+    with codecs.open(src, "r", coding) as f:
+        try:
+            pattern = 'href="javascript:if\(confirm\([^"]*"'
+            pattern_url='(https?|ftp|file)://[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]'
+            data = f.read()
+            # 获取所有正则匹配
+            out = re.findall(pattern, data, flags=0)
+            if out:
+                for eachOut in out :
+                    # 取出每个链接
+                    url='href="'+re.search(pattern_url,eachOut,flags=0).group()+'"'
+                    data=data.replace(eachOut, url)
+            WriteFile(dst, data, encoding="utf-8")
+        except Exception:
+            print(src + "  " + coding + "  read error")
+
+# 把目录中的*.java编码由gbk转换为utf-8
+
+
+def fix(rootdir):
+    for parent, dirnames, filenames in os.walk(rootdir):
+        for dirname in dirnames:
+                # 递归函数,遍历所有子文件夹
+            fix(dirname)
+        for filename in filenames:
+            if filename.endswith(".html"):
+                convert(os.path.join(parent, filename),
+                        os.path.join(parent, filename))
+
+
+if __name__ == "__main__":
+    src_path = "E:/share/linux/100/www.100.me"
+    fix(src_path)

+ 22 - 0
pom.xml

@@ -0,0 +1,22 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>me.yoqi</groupId>
+  <artifactId>me.yoqi.fix-teleport</artifactId>
+  <version>0.0.1-SNAPSHOT</version>
+  <name>fix-teleport</name>
+  <description>teleport项目修复高级功能</description>
+  <build>
+    <sourceDirectory>src</sourceDirectory>
+    <plugins>
+      <plugin>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <version>3.5.1</version>
+        <configuration>
+          <source/>
+          <target/>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+  <url>http://git.yoqi.me:3000/lyq/fix-teleport</url>
+</project>

+ 11 - 0
src/me/yoqi/Utils/FileUtils.java

@@ -0,0 +1,11 @@
+package me.yoqi.Utils;
+
+public class FileUtils {
+	public static void multiRename(){
+		
+	}
+	public static void multiFloder(){
+		 	
+	}
+	
+}

+ 21 - 0
src/me/yoqi/fix/Main.java

@@ -0,0 +1,21 @@
+package me.yoqi.fix;
+
+import java.io.File;
+
+public class Main {
+
+	public static void main(String[] args) {
+//		href="javascript:if\(confirm\([^"]*"
+		String filepath="";
+		File file = new File(filepath);
+		if (!file.isDirectory()) {
+			System.out.println("---------- 该文件不是一个目录文件 ----------");
+		}else{
+			System.out.println("---------- 很好,这是一个目录文件夹 ----------");
+			String[] filelist = file.list();
+		}
+				
+	}
+	
+}
+