Skip to content

Commit

Permalink
Add changes for 98983e4
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed May 1, 2024
1 parent d4002a9 commit cd91cda
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 12 deletions.
32 changes: 22 additions & 10 deletions _modules/sarracenia.html
Original file line number Diff line number Diff line change
Expand Up @@ -888,11 +888,23 @@ <h1>Source code for sarracenia</h1><div class="highlight"><pre>
<span class="p">])</span>
<span class="k">if</span> <span class="n">new_dir</span><span class="p">:</span>
<span class="n">msg</span><span class="p">[</span><span class="s1">&#39;new_dir&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">new_dir</span>
<span class="k">elif</span> <span class="s1">&#39;new_dir&#39;</span> <span class="ow">in</span> <span class="n">msg</span><span class="p">:</span>
<span class="n">new_dir</span> <span class="o">=</span> <span class="n">msg</span><span class="p">[</span><span class="s1">&#39;new_dir&#39;</span><span class="p">]</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">new_dir</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>

<span class="k">if</span> <span class="n">new_file</span> <span class="ow">or</span> <span class="n">new_file</span> <span class="o">==</span> <span class="s1">&#39;&#39;</span><span class="p">:</span>
<span class="n">msg</span><span class="p">[</span><span class="s1">&#39;new_file&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">new_file</span>

<span class="n">relPath</span> <span class="o">=</span> <span class="n">new_dir</span> <span class="o">+</span> <span class="s1">&#39;/&#39;</span> <span class="o">+</span> <span class="n">new_file</span>
<span class="k">elif</span> <span class="s1">&#39;new_file&#39;</span> <span class="ow">in</span> <span class="n">msg</span><span class="p">:</span>
<span class="n">new_file</span> <span class="o">=</span> <span class="n">msg</span><span class="p">[</span><span class="s1">&#39;new_file&#39;</span><span class="p">]</span>
<span class="k">elif</span> <span class="s1">&#39;new_relPath&#39;</span> <span class="ow">in</span> <span class="n">msg</span><span class="p">:</span>
<span class="n">new_file</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">basename</span><span class="p">(</span><span class="n">msg</span><span class="p">[</span><span class="s1">&#39;rel_relPath&#39;</span><span class="p">])</span>
<span class="k">elif</span> <span class="s1">&#39;relPath&#39;</span> <span class="ow">in</span> <span class="n">msg</span><span class="p">:</span>
<span class="n">new_file</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">basename</span><span class="p">(</span><span class="n">msg</span><span class="p">[</span><span class="s1">&#39;relPath&#39;</span><span class="p">])</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">new_file</span> <span class="o">=</span> <span class="s1">&#39;ErrorInSarraceniaMessageUpdatePaths.txt&#39;</span>

<span class="n">newFullPath</span> <span class="o">=</span> <span class="n">new_dir</span> <span class="o">+</span> <span class="s1">&#39;/&#39;</span> <span class="o">+</span> <span class="n">new_file</span>

<span class="c1"># post_baseUrl option set in msg overrides other possible options</span>
<span class="k">if</span> <span class="s1">&#39;post_baseUrl&#39;</span> <span class="ow">in</span> <span class="n">msg</span><span class="p">:</span>
Expand Down Expand Up @@ -921,23 +933,23 @@ <h1>Source code for sarracenia</h1><div class="highlight"><pre>
<span class="n">pbd_str</span> <span class="o">=</span> <span class="n">options</span><span class="o">.</span><span class="n">variableExpansion</span><span class="p">(</span><span class="n">options</span><span class="o">.</span><span class="n">post_baseDir</span><span class="p">,</span> <span class="n">msg</span><span class="p">)</span>
<span class="n">parsed_baseUrl</span> <span class="o">=</span> <span class="n">sarracenia</span><span class="o">.</span><span class="n">baseUrlParse</span><span class="p">(</span><span class="n">baseUrl_str</span><span class="p">)</span>

<span class="k">if</span> <span class="n">relPath</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="n">pbd_str</span><span class="p">):</span>
<span class="n">relPath</span> <span class="o">=</span> <span class="n">new_dir</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">pbd_str</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39;/&#39;</span> <span class="o">+</span> <span class="n">new_file</span>
<span class="k">if</span> <span class="n">newFullPath</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="n">pbd_str</span><span class="p">):</span>
<span class="n">newFullPath</span> <span class="o">=</span> <span class="n">new_dir</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">pbd_str</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39;/&#39;</span> <span class="o">+</span> <span class="n">new_file</span>

<span class="k">if</span> <span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">parsed_baseUrl</span><span class="o">.</span><span class="n">path</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">)</span> <span class="ow">and</span> <span class="n">relPath</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span>
<span class="k">if</span> <span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">parsed_baseUrl</span><span class="o">.</span><span class="n">path</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">)</span> <span class="ow">and</span> <span class="n">newFullPath</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span>
<span class="n">parsed_baseUrl</span><span class="o">.</span><span class="n">path</span><span class="p">):</span>
<span class="n">relPath</span> <span class="o">=</span> <span class="n">relPath</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">parsed_baseUrl</span><span class="o">.</span><span class="n">path</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
<span class="n">newFullPath</span> <span class="o">=</span> <span class="n">newFullPath</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">parsed_baseUrl</span><span class="o">.</span><span class="n">path</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>

<span class="k">if</span> <span class="p">(</span><span class="s1">&#39;new_dir&#39;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">msg</span><span class="p">)</span> <span class="ow">and</span> <span class="n">options</span><span class="o">.</span><span class="n">post_baseDir</span><span class="p">:</span>
<span class="n">msg</span><span class="p">[</span><span class="s1">&#39;new_dir&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">options</span><span class="o">.</span><span class="n">post_baseDir</span>

<span class="n">msg</span><span class="p">[</span><span class="s1">&#39;new_baseUrl&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">baseUrl_str</span>

<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">relPath</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">0</span> <span class="ow">and</span> <span class="n">relPath</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="s1">&#39;/&#39;</span><span class="p">:</span>
<span class="n">relPath</span> <span class="o">=</span> <span class="n">relPath</span><span class="p">[</span><span class="mi">1</span><span class="p">:]</span>
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">newFullPath</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">0</span> <span class="ow">and</span> <span class="n">newFullPath</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="s1">&#39;/&#39;</span><span class="p">:</span>
<span class="n">newFullPath</span> <span class="o">=</span> <span class="n">newFullPath</span><span class="p">[</span><span class="mi">1</span><span class="p">:]</span>

<span class="n">msg</span><span class="p">[</span><span class="s1">&#39;new_relPath&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">relPath</span>
<span class="n">msg</span><span class="p">[</span><span class="s1">&#39;new_subtopic&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">relPath</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;/&#39;</span><span class="p">)[</span><span class="mi">0</span><span class="p">:</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span>
<span class="n">msg</span><span class="p">[</span><span class="s1">&#39;new_relPath&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">newFullPath</span>
<span class="n">msg</span><span class="p">[</span><span class="s1">&#39;new_subtopic&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">newFullPath</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;/&#39;</span><span class="p">)[</span><span class="mi">0</span><span class="p">:</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span>

<span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="p">[</span><span class="s1">&#39;relPath&#39;</span><span class="p">,</span> <span class="s1">&#39;subtopic&#39;</span><span class="p">,</span> <span class="s1">&#39;baseUrl&#39;</span><span class="p">]:</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">msg</span><span class="p">:</span>
Expand Down
6 changes: 5 additions & 1 deletion _modules/sarracenia/flow.html
Original file line number Diff line number Diff line change
Expand Up @@ -2050,7 +2050,11 @@ <h1>Source code for sarracenia.flow</h1><div class="highlight"><pre>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">o</span><span class="o">.</span><span class="n">dry_run</span><span class="p">:</span>
<span class="n">cwd</span> <span class="o">=</span> <span class="n">cdir</span>
<span class="k">else</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">proto</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">scheme</span><span class="p">]</span><span class="o">.</span><span class="n">cd</span><span class="p">(</span><span class="n">cdir</span><span class="p">)</span>
<span class="k">try</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">proto</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">scheme</span><span class="p">]</span><span class="o">.</span><span class="n">cd</span><span class="p">(</span><span class="n">cdir</span><span class="p">)</span>
<span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">ex</span><span class="p">:</span>
<span class="n">logger</span><span class="o">.</span><span class="n">error</span><span class="p">(</span><span class="s2">&quot;chdir </span><span class="si">%s</span><span class="s2">: </span><span class="si">%s</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">cdir</span><span class="p">,</span> <span class="n">ex</span><span class="p">))</span>
<span class="k">return</span> <span class="kc">False</span>

<span class="n">remote_offset</span> <span class="o">=</span> <span class="mi">0</span>
<span class="n">exactLength</span><span class="o">=</span><span class="kc">False</span>
Expand Down
3 changes: 2 additions & 1 deletion _modules/sarracenia/transfer/sftp.html
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,10 @@ <h1>Source code for sarracenia.transfer.sftp</h1><div class="highlight"><pre>

<span class="c1"># cd</span>
<span class="k">def</span> <span class="nf">cd</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">path</span><span class="p">):</span>
<span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s2">&quot;sr_sftp cd </span><span class="si">%s</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="n">path</span><span class="p">)</span>
<span class="n">alarm_set</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">o</span><span class="o">.</span><span class="n">timeout</span><span class="p">)</span>
<span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s2">&quot;first cd to </span><span class="si">%s</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="bp">self</span><span class="o">.</span><span class="n">originalDir</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">sftp</span><span class="o">.</span><span class="n">chdir</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">originalDir</span><span class="p">)</span>
<span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s2">&quot;then cd to </span><span class="si">%s</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="n">path</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">sftp</span><span class="o">.</span><span class="n">chdir</span><span class="p">(</span><span class="n">path</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">pwd</span> <span class="o">=</span> <span class="n">path</span>
<span class="n">alarm_cancel</span><span class="p">()</span>
Expand Down

0 comments on commit cd91cda

Please sign in to comment.