Skip to content

Commit

Permalink
fixed config add arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
UltrafunkAmsterdam committed Mar 1, 2024
1 parent aec7804 commit 313f5a5
Show file tree
Hide file tree
Showing 32 changed files with 553 additions and 310 deletions.
42 changes: 22 additions & 20 deletions _update_changes.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@

import subprocess

docs = Path('docs')
example = Path('example')
dist = Path('dist')
egg = Path('nodriver.egg-info')
docs = Path("docs")
example = Path("example")
dist = Path("dist")
egg = Path("nodriver.egg-info")


def find_file(pattern: str , root: str ='.', recursive: bool =True):
def find_file(pattern: str, root: str = ".", recursive: bool = True):
root = Path(root).resolve()
glob = root.glob if not recursive else root.rglob
for o in glob(pattern):
Expand All @@ -37,12 +37,13 @@ def find_replace_in_file(file, search, repl):
else:
file.write_text(re.sub(search, repl, content))


def remove(path):
path = Path(path).resolve()
if path.is_file():
path.unlink()
return True
for item in path.rglob('*'):
for item in path.rglob("*"):
if item.is_file():
item.unlink()
continue
Expand All @@ -57,31 +58,32 @@ def change_version():
new_version = None
while not new_version:
try:
new_version = Version(input(f'change version (current: {current})? : '))
new_version = Version(input(f"change version (current: {current})? : "))
except:
continue
if new_version != current:
find_replace_in_file(project_file, 'version = [\"\']([^\s]+)[\"\']', f'version = "{new_version}"')
find_replace_in_file(
project_file, "version = [\"']([^\s]+)[\"']", f'version = "{new_version}"'
)


def get_version(project_file: Path):
content = project_file.read_text()
return re.search('version = [\"\']([^\s]+)[\"\']', content)[1]

return re.search("version = [\"']([^\s]+)[\"']", content)[1]

project_file = find_file('pyproject.toml')

project_file = find_file("pyproject.toml")

subprocess.run('make.bat html', shell=True, cwd='./docs')
subprocess.run('make.bat markdown', shell=True, cwd='./docs')
subprocess.run('copy docs\\_build\\markdown\\README.md .', shell=True)
subprocess.run("make.bat html", shell=True, cwd="./docs")
subprocess.run("make.bat markdown", shell=True, cwd="./docs")
subprocess.run("copy docs\\_build\\markdown\\README.md .", shell=True)
change_version()
subprocess.run('git add docs nodriver pyproject.toml example README.md')
subprocess.run('git status')
commit = input('commit?:')
subprocess.run("black nodriver/core *.py")
subprocess.run("git add docs nodriver pyproject.toml example README.md")
subprocess.run("git status")
commit = input("commit?:")
if commit:
subprocess.run(f'git commit -m "{commit}"')

subprocess.run('python -m build')
subprocess.run('twine upload dist\\*')

subprocess.run("python -m build")
subprocess.run("twine upload dist\\*")
Binary file modified docs/_build/doctrees/environment.pickle
Binary file not shown.
Binary file not shown.
Binary file modified docs/_build/doctrees/nodriver/classes/tab.doctree
Binary file not shown.
Binary file modified docs/_build/doctrees/nodriver/quickstart.doctree
Binary file not shown.
3 changes: 3 additions & 0 deletions docs/_build/html/_modules/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@
<ul>
<li class="toctree-l1"><a class="reference internal" href="../nodriver/quickstart.html">Quickstart guide</a></li>
<li class="toctree-l1"><a class="reference internal" href="../nodriver/quickstart.html#usage-example">usage example</a></li>
<li class="toctree-l1"><a class="reference internal" href="../nodriver/quickstart.html#more-complete-example">More complete example</a></li>
<li class="toctree-l1"><a class="reference internal" href="../nodriver/quickstart.html#custom-starting-options">Custom starting options</a></li>
<li class="toctree-l1"><a class="reference internal" href="../nodriver/quickstart.html#alternative-custom-options">Alternative custom options</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../nodriver/classes/browser.html">Browser class</a></li>
Expand Down
18 changes: 9 additions & 9 deletions docs/_build/html/_modules/nodriver/core/browser.html
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../nodriver/quickstart.html">Quickstart guide</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../nodriver/quickstart.html#usage-example">usage example</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../nodriver/quickstart.html#more-complete-example">More complete example</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../nodriver/quickstart.html#custom-starting-options">Custom starting options</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../nodriver/quickstart.html#alternative-custom-options">Alternative custom options</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../nodriver/classes/browser.html">Browser class</a></li>
Expand Down Expand Up @@ -371,14 +374,13 @@ <h1>Source code for nodriver.core.browser</h1><div class="highlight"><pre>

<span class="bp">self</span><span class="o">.</span><span class="n">targets</span><span class="p">:</span> <span class="n">List</span> <span class="o">=</span> <span class="p">[]</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;current targets (all types&quot;&quot;&quot;</span>

<span class="bp">self</span><span class="o">.</span><span class="n">_process</span> <span class="o">=</span> <span class="kc">None</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_process_pid</span> <span class="o">=</span> <span class="kc">None</span>
<span class="bp">self</span><span class="o">.</span><span class="n">info</span> <span class="o">=</span> <span class="kc">None</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_target</span> <span class="o">=</span> <span class="kc">None</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_process</span> <span class="o">=</span> <span class="kc">None</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_process_pid</span> <span class="o">=</span> <span class="kc">None</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_keep_user_data_dir</span> <span class="o">=</span> <span class="kc">None</span>
<span class="bp">self</span><span class="o">.</span><span class="n">connection</span><span class="p">:</span> <span class="n">Connection</span> <span class="o">=</span> <span class="kc">None</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_is_updating</span> <span class="o">=</span> <span class="n">asyncio</span><span class="o">.</span><span class="n">Event</span><span class="p">()</span>
<span class="bp">self</span><span class="o">.</span><span class="n">connection</span><span class="p">:</span> <span class="n">Connection</span> <span class="o">=</span> <span class="kc">None</span>
<span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s2">&quot;Session object initialized: </span><span class="si">%s</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="nb">vars</span><span class="p">(</span><span class="bp">self</span><span class="p">))</span>

<span class="nd">@property</span>
Expand Down Expand Up @@ -455,7 +457,6 @@ <h1>Source code for nodriver.core.browser</h1><div class="highlight"><pre>
<span class="p">)</span>
<span class="n">current_tab</span><span class="o">.</span><span class="n">target</span> <span class="o">=</span> <span class="n">target_info</span>


<span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">event</span><span class="p">,</span> <span class="n">cdp</span><span class="o">.</span><span class="n">target</span><span class="o">.</span><span class="n">TargetCreated</span><span class="p">):</span>
<span class="n">target_info</span><span class="p">:</span> <span class="n">cdp</span><span class="o">.</span><span class="n">target</span><span class="o">.</span><span class="n">TargetInfo</span> <span class="o">=</span> <span class="n">event</span><span class="o">.</span><span class="n">target_info</span>
<span class="kn">from</span> <span class="nn">.tab</span> <span class="kn">import</span> <span class="n">Tab</span>
Expand Down Expand Up @@ -529,7 +530,6 @@ <h1>Source code for nodriver.core.browser</h1><div class="highlight"><pre>
<span class="p">)</span>
<span class="p">)</span>


<span class="k">else</span><span class="p">:</span>
<span class="c1"># first tab from browser.tabs</span>
<span class="n">connection</span> <span class="o">=</span> <span class="nb">next</span><span class="p">(</span><span class="nb">filter</span><span class="p">(</span><span class="k">lambda</span> <span class="n">item</span><span class="p">:</span> <span class="n">item</span><span class="o">.</span><span class="n">type_</span> <span class="o">==</span> <span class="s2">&quot;page&quot;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">targets</span><span class="p">))</span>
Expand All @@ -556,9 +556,9 @@ <h1>Source code for nodriver.core.browser</h1><div class="highlight"><pre>
<span class="k">return</span>

<span class="c1"># self.config.update(kwargs)</span>
<span class="n">connect_exisiting</span> <span class="o">=</span> <span class="kc">False</span>
<span class="n">connect_existing</span> <span class="o">=</span> <span class="kc">False</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">config</span><span class="o">.</span><span class="n">host</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">config</span><span class="o">.</span><span class="n">port</span><span class="p">:</span>
<span class="n">connect_exisiting</span> <span class="o">=</span> <span class="kc">True</span>
<span class="n">connect_existing</span> <span class="o">=</span> <span class="kc">True</span>
<span class="bp">self</span><span class="o">.</span><span class="n">config</span><span class="o">.</span><span class="n">host</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">config</span><span class="o">.</span><span class="n">host</span> <span class="ow">or</span> <span class="s2">&quot;127.0.0.1&quot;</span>
<span class="bp">self</span><span class="o">.</span><span class="n">config</span><span class="o">.</span><span class="n">port</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">config</span><span class="o">.</span><span class="n">port</span> <span class="ow">or</span> <span class="n">util</span><span class="o">.</span><span class="n">free_port</span><span class="p">()</span>

Expand All @@ -585,7 +585,7 @@ <h1>Source code for nodriver.core.browser</h1><div class="highlight"><pre>
<span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span>
<span class="s2">&quot;starting</span><span class="se">\n\t</span><span class="s2">executable :</span><span class="si">%s</span><span class="se">\n\n</span><span class="s2">arguments:</span><span class="se">\n</span><span class="si">%s</span><span class="s2">&quot;</span><span class="p">,</span> <span class="n">exe</span><span class="p">,</span> <span class="s2">&quot;</span><span class="se">\n\t</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">params</span><span class="p">)</span>
<span class="p">)</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">connect_exisiting</span><span class="p">:</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">connect_existing</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_process</span><span class="p">:</span> <span class="n">asyncio</span><span class="o">.</span><span class="n">subprocess</span><span class="o">.</span><span class="n">Process</span> <span class="o">=</span> <span class="p">(</span>
<span class="k">await</span> <span class="n">asyncio</span><span class="o">.</span><span class="n">create_subprocess_exec</span><span class="p">(</span>
<span class="c1"># self.config.browser_executable_path,</span>
Expand Down
Loading

0 comments on commit 313f5a5

Please sign in to comment.